Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Why can't I call history in before_trading_start()?

This is what I have:

def before_trading_start(context):  
    volume_history = history(bar_count=2, frequency='1d', field='volume')  
    log.info("Volume %s" % str(volume_history))  

But it doesn't work:

Error 'history' only permitted within before_trading_start function

I see in the reference that history() is always used in handle_data(), and it works there, but why not in before_trading_start() ?

1 response