Issues with MACD Calculations
See original GitHub issueWhich version are you running? The lastest version is on Github. Pip is for major releases.
import pandas_ta as ta
print(ta.version)
0.3.14b0
Do you have TA Lib also installed in your environment?
$ pip list
Package Version
---------------------------------------
alpaca-trade-api 1.4.3
dataclasses 0.8
graphviz 0.19.1
ipykernel 6.7.0
ipython 8.0.0
ipython-genutils 0.2.0
joblib 1.1.0
jsonschema 4.4.0
jupyter-client 7.1.1
jupyter-core 4.9.1
jupyterlab-pygments 0.1.2
matplotlib 3.5.1
matplotlib-inline 0.1.3
numpy 1.22.1
pandas 1.3.5
pandas-datareader 0.10.0
pandas-ta 0.3.14b0
requests 2.27.1
scikit-learn 1.0.2
scipy 1.7.3
seaborn 0.11.2
setuptools 60.5.0
six 1.16.0
sklearn 0.0
Did you upgrade? Did the upgrade resolve the issue?
$ pip install -U git+https://github.com/twopirllc/pandas-ta
I upgraded…
Describe the bug The bug is probably me… but it doesn’t make sense. I’m using the same data which I will provide, I hope via attachment. The code is simple -
# get data from Alpaca - SIP feed and calc MACD, MACDs
symbol='SQQQ'
mdf = api.get_bars(symbol, TimeFrame(30, TimeFrameUnit.Minute), "2022-02-14", "2022-02-15", adjustment='raw').df
mdf.ta.macd(append=True)
When I do this. the values for 2-15 15:00 are Negative. 13:00 to 15:00 Rising. But SQQQ was running up into 13:00 and then reversed Down at 14:00. So my computation is the complete opposite.? I have it negative going to positive instead of positive going to negative.
A clear and concise description of what the bug is.
To Reproduce
Provide sample code. Sample code above.
Expected behavior I did verify the data in the Alpaca produced chart is the same as the data I’m using.
Screenshots
Additional context Data csv below
Thanks for using Pandas TA!
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (7 by maintainers)
Top GitHub Comments
@schwaa,
I’m not keen on Alpaca data. But any broker is subject to misprints and missing values when live streaming and even post-hoc. But whomever the broker is that you are placing actual transactions with, whether it’s IB, Alpaca, TDA, et al., you will have to trust their data at some point.
I understand.
However I am unconvinced that PTA is the issue here as it’s indicator values are consistent with TA Lib, primary purpose of PTA, and core TV indicators, ancillary. So when I see claims that an indicator, especially a core one, is not working, I get nervous. 😓 Don’t forget, for some indicators, that you need a larger set of bars to avoid the Unstable Period; you will have to figure out what is the minimum necessary bars to get expected values. I am using the max bars, 10235, I could get from TV for this comparison, but certainly you can converge with much less.
Your Data
More Data (Max from TV)
CSV: BATS_SQQQ_30_schwaa_macd_max
Sanity Plots
Correlation
Row wise Comparison
Hope this helps!
KJ
The OHLCV data values ARE equal bar by bar with Alpaca. Both the chart and the data are coming from Alpaca. And I verified and handful of spot bars visually.