I've made a CSV that contains S&P500 companies on a quarterly basis. The CSV consists of a Date
column, and a symbol
column. For every quarter, I have 500 rows that contain the date and a symbol for every stock that exists in the S&P500 on that specific date. I'm trying to fetch this data and would like to use these companies in my pipeline, but I'm getting this error when backtesting:
TypeError: 'NoneType' object has no attribute '__getitem__'
It's included in my code, but here's a link to the CSV file I've made with the S&P500 stocks I would like to use between the quarterly intervals:
https://dl.dropboxusercontent.com/s/r52vebo1utaxyoa/sp500_for_quantopian.csv?dl=0
Also, how would I then make it so my pipeline universe are the stocks listed in the CSV while still being able to get data back on those securities. Here's what I'm currently doing with the Q500US universe, which I would like to replace with the stocks in my CSV:
def make_pipeline(context):
market_cap = MarketCap()
rolling_correlations = RollingLinearRegressionOfReturns(
target = context.regression_target,
returns_length = context.regression_returns_length,
regression_length = context.regression_length,
mask = context.base_universe
)
beta = rolling_correlations.beta
should_buy_beta = (beta < context.beta_threshold)
securities_to_trade = (context.base_universe & should_buy_beta)
return Pipeline(
columns = {
'market_cap': market_cap,
'beta': beta,
'should_buy_beta': should_buy_beta,
'securities_to_trade': securities_to_trade
},
screen = (securities_to_trade)
)