ta-lib-python
ta-lib-python copied to clipboard
Streaming API does not give the same result
For some functions it is not working well:
import numpy as np
import talib
from talib import stream
close = np.array([.5, .7, .7, .6, .7, .8, .7, .7, .7, .6, .5, .5, .6, .6, .7, .8, .7, .7, .7, .6, .5, .5, .6])
print(talib.CMO(close)[-1])
print(stream.CMO(close))
The results are:
4.209286980682376
-11.111111111111105
I believe this issue is due to "memory" in the Function API that is not available in the Streaming API.
>>> a = np.random.randn(15)
# with exact same data:
>>> talib.CMO(a, 14)
array([ nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan,
nan, nan, nan, nan, -1.06910005])
>>> stream.CMO(a, 14)
-1.069100046167708
# with more data in the history
>>> talib.CMO(a, 5)
array([ nan, nan, nan, nan,
nan, 13.15890374, 14.02364124, -13.26545769,
2.12746979, 16.41988121, 0.44171192, -44.24433125,
14.87262214, -2.22058414, -3.00791912])
>>> stream.CMO(a, 5)
-14.102062814919664
(The Streaming API only considers timeperiod observations)
Oh, I see. Thanks!