Closed fypdoctave closed 4 years ago
Hello @fypdoctave,
Thanks! Glad you find it useful.
I have addressed calculation issues before with Issue #23.
Now I do not use Yahoo Finance nor StockCharts for TA comparisons. They do not list what TA Library that they use or if it's proprietary. StockCharts does not address it anywhere on their FAQ. I will be not cross referencing with YF' RSI (for example) because I can only export the historical data and not it's RSI calculations without having to transcribe the RSI values from the chart to a CSV by hand and then run correlation tests. Likewise, I will not be using SC because I do not have an account and I'm sure it is the same cumbersome process just to compare indicators for correlations as well. I do use TradingView for two purposes when developing pandas_ta
indicators: visual test of output and if needed easy export of data to CSV.
You are correct, there are some indicators that are not exact. These can be found by running python -m unittest -v
if you also have TA=Lib installed. I run a correlation test between the pandas_ta
indicators versus those that are implemented in TA-Lib
. Indicators that are not greater than 99% correlated and implemented in TA-Lib
include: APO, CCI, CMO, STOCH, ADX, AROON Down & Up, BB Upper and Lower Bands, and AD (open)
.
Are the indicators that are less than 99% correlated less than desirable? Certainly. Could they be improved? Of course, I would like to improve them. But sadly, I have spent more time on them than I thought just to get them to their current percentage of correlation. Nevertheless, there will be some lack of 1-to-1 correspondence between different libraries (and languages) because floating point calculations are imperfect.
Regarding:
ta.rsi
: When the length is greater than 21, only then does rsi
begin to deviate from TA-Lib's RSI.ta.stoch
: I ran a quick test with swapping 'slow_k' with 'fast_k' as suggested. Using 'slow_k', the correlations with TA Lib are:
With your suggestion with 'fast_k' instead, yielded the following correlations with TA Lib:
ta.atr
is 99% correlated with TA Lib.I hope that this has addressed most of your concerns regarding the indicators in question and their accuracy. In your quest to learn more about Technical Indicators and their calculations, this is a good start. Since I know absolutely nothing about you, I recommend learning about TA by writing your own on TradingView using their language called Pinescript. Pinescript is very easy to use in contrast to Python and allows you to immediately see your results.
Since you recently joined Github, welcome! However, may I also recommend installing other Open Source TA Library Repositories and test their libraries for calculation and comparison and let me know what you think?
Hope this helps, KJ
Thank you KJ for taking the time and explaining. I will definitely utilize some of the packages you mentioned above.
Hi,
I have been using your library to understand TA. First off, thank you for the amazing work. It has been really useful to have!
Wherever possible, I have been double checking the indicator values calculated either on Yahoo Finance (YF) or StockCharts (SC). As such, I wanted to ask for some clarifications on couple of things:
Using df.ta.rsi(length=14) gives me RSI results that are little bit off from YF or SC or manual calculation in excel. However, with df.ta.rsi(length=13), results pretty match with YF (Period 14) or manual work (again using 14 periods). I am not sure why there is a mismatch with ta.rsi default value of 14. Can you please check?
In df.ta.stoch(), I noticed calling with default values gave different results from YF/SC. Digging deeper, in stoch.py, lines 18 & 19, I'm thinking shouldn't the value used be fast_k instead of slow_k. If I update the below to fast_k, I do get matching results with both sources mentioned. Maybe you had something else in mind while implementing?
Calculate Result
First TR14 = Sum of first 14 periods of TR1 Second TR14 = First TR14 - (First TR14/14) + Current TR1 Subsequent Values = Prior TR14 - (Prior TR14/14) + Current TR1
as explained here: https://school.stockcharts.com/doku.php?id=technical_indicators:average_directional_index_adx
I'm not sure what the above smoothing methodology is called but can you please comment on the difference? Also, is there way to use your existing functions to implement this smoothing method?
Sorry for the long post. I greatly appreciate your work and am trying to understand as much as possible. Any further help is greatly appreciated too!