error:
zipline api method symbol must be called during a simulation. why this error occure?
error:
zipline api method symbol must be called during a simulation. why this error occure?
Short answer: You probably called the function symbol
outside any function in your code. That is illegal.
Long answer: You can use symbol
only in the entry-point functions like initialize
or handle_data
etc, or inside a function (that you define) that gets (eventually) called from any of these entry-point functions. The function symbol
resolves a string (a stock ticker) to an asset object. To do that, it uses references to other internal objects that are available only within the simulation, i.e. within these functions.