AttributeError: 'TradingAlgorithm' object has no attribute 'universe'

Hello,

I just starting with blueshift.

For practice I am running the code found in the documentation :https://blueshift.quantinsti.com/docs/datafetch/#using-the-fetched-data



When running the code I get this error:

AttributeError: 'TradingAlgorithm' object has no attribute 'universe'

with:


from zipline.api import symbol, order_target_percent
 
def initialize(context):
context.portf = [symbol('AMZN')]
 
def handle_data(context, data):
px1 = data.history(context.universe[0], "close", 10, "1m")
px2 = data.history(context.universe, "close", 10, "1m")
px3 = data.history(context.universe[0], ["open","close"], 10, "1m")
px4 = data.history(context.universe, ["open","close"], 10, "1m")
 
What am I missing ?

Thank you,
Jamarcus
 

Hi Jamarcus,



The code is trying to find where you defined the 'universe' variable. You seem to have renamed it into 'portf'.

Can you please try changing the code in the initialize function to:

context.universe= [symbol('AMZN')]



Hope this helps!