Hi guys,
I'm not able to make it works properly, because it continuously throws an Exception: inputs are all NaN... Any ideas? How I could use talib.ADX as a Custom Factor without this try:-except ??
I think this might be a bug in quantopian talib implementation, don`t u?
Thanks
# Create custom factor subclass to calculate ADX(11) for screening stocks
class AdxFactor(CustomFactor):
# Pre-declare inputs and window_length
inputs = [USEquityPricing.close, USEquityPricing.high, USEquityPricing.low]
window_length=11
def compute(self, today, assets, out, close_p, highs, lows):
adx = np.empty(len(close_p.T), dtype=np.float64)
i=0
while i<len(close_p.T):
try:
adx[i] = talib.ADX(highs.T[i], lows.T[i], close_p.T[i], timeperiod=11)[-1]
except Exception as e:
print ("Unexpected error: {0}".format(e))
i=i+1
out[:] = adx