Repository navigation
fix: qtpylib cci uses mean deviation over the window - #855
jayhemnani9910 wants to merge 1 commit into
Conversation
np.std of the whole rolling-mean column put CCI on the wrong scale and made past bars change with later candles.
xmatthias
left a comment
There was a problem hiding this comment.
I feel the need to point you to our AI contributing policy - which clearly states:
Never let an LLM speak for you - all comments, issues and PR descriptions should be written in your own words, reflecting your own understanding.
We expect everyone in this org to follow this - otherwise we'll be limiting your interactions with this organization.
If we assume that the calculation should match ta-lib - we should call ta-lib instead of reimplementing the calculation "by hand".
maybe even marked with a comment about deprecation to use Ta-lib directly.
I'll be closing this here as i think this has to be redone from scratch (essentially every line here will need changing) - though i'll keep the issue open as it reports a real issue.
| assert rma(dataframe, 5).isna().all() | ||
|
|
||
|
|
||
| def test_qtpylib_cci_matches_talib(testdata_1m_btc): |
There was a problem hiding this comment.
This test doesn't cover actual problems (constant prices return NaN here - ta-lib returns 0.0).
There's also floating point errors depending on values - so it's may be matching ta-lib for this particular scenario - but that statement doesn't generalize.
It's also tons of times slower (as data amount increases).
qtpylib.ccidivided bynp.stdof the whole rolling-mean column instead of the mean deviation over the window. The values were on the wrong scale, so the usual ±100 levels stopped meaning anything: on 500 random candles the last bar read -24.3 where TA-LibCCIgives -156.0. A past bar's value also changed as later candles came in.It now uses the rolling mean absolute deviation and matches TA-Lib
CCIon the 1m BTC test data. The new test fails before the change and passes after. The rest of the suite passes; I left outtest_pip_audit, which audits the installed packages.