Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Correct Stochastic Values

I'm struggling with stochastic values, the numbers don't match any charting sites out there that I can find.
Hope someone can shed some light on it.

%K values for AXP and two dates picked randomly:

               Quantopian    Yahoo        Google        TradingView    YCharts  
Date          (14,3,3)?      Slow(14,3)   Slow(14,3)    (14,3,3)       Slow(14,3)  
2014-4-4      33.04          21.28        21.99         21.99          21.99  
2014-4-24     76.28          39.86        43.36         43.37          43.36
6 responses

If optInSlowK_Period is 1 here it should be 3, however I think the results are the same.

I'm not directly familiar with the stoch transformation in ta-lib, but according to the formula, it's based on the close and low prices. On Quantopian, we use a private data vendor to provide our historical prices. These prices are the aggregate of all intra-day stock activity across the major exchanges: NYSE, NASDAQ, AMEX and all Consolidated Tape Association (CTA) participants. So the close_price will be the price of stock at 4:00PM.

Conversely, Yahoo/Google and other sources use adjusted close prices in their graphs. Their close_price includes the trade activity in the dark pools and close auctions, which can fluctuate the price of the stock during non-market hours. This seems to be the culprit driving the differences that you're seeing.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Two problems You need to set it to 14,3,3. 14,3,1, is ok, since you are not using the signal line, but 14,1,3 is, as they say in Monty Python, 'Right Out'.
Second, your constants are wrong. Here is my version.

The problem was in the switch names like optInFastK_Period.
Should have been fastk_period.
Then the values are nearly identical to Google and TradingView for example.

Hope someone can fix this evidently failed effort to compare/record talib.STOCH() vs ta.STOCH()

talib.stoch vs ta.stoch (7/2014)

ta.STOCH() helps identify ideal buy/sell points along with other indicators in my algo.
With ta to-be-deprecated it makes sense to be prepared with an accurate talib replacement.
In the following, ta.STOCH() is pretty close to accurate (acceptable) and talib.STOCH() is better than above yet inaccurate.
This also has a manual stochastics calculation, pretty close to talib and therefore also inaccurate.