Open grantfang opened 5 years ago
Your second comment is a problem where inputs have to be doubles and your input (a = np.array([1,1,1,1,1,1,1,1,1])
) is a numpy array of integers...
The first, I'm not sure, perhaps nan
interrupts the underling TA-Lib algorithm, you can see the code here where it does a rolling algorithm and nan
problem pollutes all future values:
https://github.com/TA-Lib/ta-lib/blob/master/src/ta_func/ta_CORREL.c#L245
yeah, unfortunately I am only familiar with python
Snippet as demonstration:
In[1]:import talib
In[2]:import numpy as np
In[3]:a = np.array([1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]) #9 elements in total
In[4]:b = np.array([9.0,8.0,7.0,np.nan,5.0,4.0,3.0,2.0,1.0]) #9 elements as well, nan appears on 4th
In[5]:talib.CORREL(a,b,timeperiod=3)
Out[5]: array([nan, nan, -1., nan, nan, nan, nan, nan, nan])
So with missing value in one array, I expect the result to be:
array([nan, nan, -1., nan, nan, nan, -1, -1, -1])
That is, in any timeperiod window, if both array are with no nan value, a correlation should present. Current result is that after first nan value, all result afterwards become nan.Another trivial thing I noticed while making the snippet if
a = np.array([1,1,1,1,1,1,1,1,1])