Hi,
I am filtering stocks based on the results of the Augmented Dickey Fuller test as follows:
class ADF_test(CustomFactor):
# Pre-declare inputs and window_length
inputs = [USEquityPricing.close]
window_length = 100
def compute(self, today, assets, out, close):
for i in range(close.shape[1]):
price_col = close[:,i]
price_col = price_col[~np.isnan(price_col)]
if len(price_col) >= 100:
adf_result = adfuller(price_col)
if adf_result[0] < adf_result[4]['5%']:
out[:] = True
else:
out[:] = False
else:
out[:] = False
Now, i dont know if its the right way but so far, the results seem to make sense.
Further in the code I call a filter based on the ADF result as follows:
def my_pipeline(context):
"""
A function to create our dynamic stock selector (pipeline). Documentation on
pipeline can be found here: https://www.quantopian.com/help#pipeline-title
"""
pipe = Pipeline()
adf_result= ADF_test()
pipe.add(adf_result, 'adf_result')
pipe.set_screen(adf_result = True)
return pipe
but I end up with this error:
TypeError: set_screen() got an unexpected keyword argument 'adf_result'
...
USER ALGORITHM:76, in my_pipeline
pipe.set_screen(adf_result = True)
Can anyone help ? Is this the optimal way to do this ?
Thanks !