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() ?