Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
documentation small question

In the documentation

def handle_data(context, data):  
    price_history = history(bar_count=30, frequency='1d', field='price')  
    my_sid_series = price_history[context.my_sid]  
    ema_result = talib.EMA(my_sid_series)  
    record(ema=ema_result[-1])  

what i do not understand is why need to do
my_sid_series = price_history[context.my_sid] Since I thought the price_history == my_sid_series as there's only one stock here

Any help appreciated.

1 response

Well, there is no difference whether you work with one stock or multiple ones. You always fetch the history the same way:

price_history[sid]  

That's it. The index is useful if you deal with many stocks, but if you work with a single one, you still need to indicate it.