I'm working to convert an algo over to Q2 and encountered:
There was a runtime error.
AttributeError: 'zipline._protocol.SidView' object has no attribute 'Metric'
USER ALGORITHM:254, in CalculateWeighting
data[stock].Metric = allocation[k]
So, I guess the question is how do I cook something up like this:
dat[stock].Metric
The list of keys would need to be limited to stocks that the algo should be trading at any point in time (algo presently uses
update_universe
periodically). So, I suppose in before_trading_start
I would see what stocks are in the portfolio and which ones are to be added, dropping everything else from dat[stock]
(which is what update_universe
was doing).