in a pipeline algorithm, I am restricting my known universe, then I want to loop over my base_universe. I get the following error from this code. Much of the code was copied from a lecture or tutorial.
zipline.pipeline.term.__getitem__() expected a value of type zipline.assets._assets.Asset for argument 'key', but got int instead.
# Filter for primary share equities. IsPrimaryShare is a built-in filter. primary_share = IsPrimaryShare() # Equities listed as common stock (as opposed to, say, preferred stock). # 'ST00000001' indicates common stock. common_stock = morningstar.share_class_reference.security_type.latest.eq('ST00000001') # Non-depositary receipts. Recall that the ~ operator inverts filters, # turning Trues into Falses and vice versa not_depositary = ~morningstar.share_class_reference.is_depositary_receipt.latest # Equities not trading over-the-counter. not_otc = ~morningstar.share_class_reference.exchange_id.latest.startswith('OTC') # Not when-issued equities. not_wi = ~morningstar.share_class_reference.symbol.latest.endswith('.WI') # Equities without LP in their name, .matches does a match using a regular # expression not_lp_name = ~morningstar.company_reference.standard_name.latest.matches('.* L[. ]?P.?$') # Equities with a null value in the limited_partnership Morningstar # fundamental field. not_lp_balance_sheet = morningstar.balance_sheet.limited_partnership.latest.isnull() # Equities whose most recent Morningstar market cap is not null have # fundamental data and therefore are not ETFs. have_market_cap = morningstar.valuation.market_cap.latest.notnull() # Filter for stocks that pass all of our previous filters. tradeable_stocks = ( primary_share & common_stock & not_depositary & not_otc & not_wi & not_lp_name & not_lp_balance_sheet & have_market_cap ) days_volume = 20 # High dollar volume filter. base_universe = AverageDollarVolume(window_length=days_volume, mask=tradeable_stocks).top(40) for symbol in base_universe: print(symbol)