bt.talib.CORREL not working properly
For the indicator
bt.talib.CORREL, if I pass in two indicators with missing values in the middle, no correlation will be calculated after the first missing value, even the values are there afterward, as a demonstration(a and b are both line object, i only show them as array here):
import numpy as np a = np.array([1,1,1,1 ,1,1,1,1,1]) #space on 4th element is for readability b = np.array([1,1,1,np.nan,1,1,1,1,1]) print(bt.talib.CORREL(a,b,timepriod=3)) >> [nan,nan,1,nan,nan,nan,nan,nan,nan]
The intended result should be:
In my actual case, both a and b are about 300 days long, and the missing values is about 30 days long in the middle of one data, and I tried to calculate correlation for a 6 days window, not sure if this has to do with issue. All the value before missing ones are correct.
I don't understand what your expectations are.
- The code is broken (redacted, extracted and broken)
- It is an external function from an external library (have you tried directly with
I do truly believe you are posting in the wrong forum.