Strategy Properties¶
Inside your strategy you can also get a lot of information about the state of the strategy and set specific variables to determine how the strategy works. Here is a list of those properties that you can use:
|
Returns the current cash. |
|
Returns the last portfolio value (cash + positions value) reported by the broker. |
|
|
|
Returns True if this is the first iteration of the strategy (is True if the lifecycle method on_trading_iteration is being excuted for the first time). |
|
Boolean flag indicating whether the strategy is running in backtesting mode. |
|
Returns the quote asset for the strategy. |
|
Returns the name of the strategy. |
|
Returns the strategy's starting value. |
|
Get or set the number of minutes that the strategy will stop executing before market closes. |
|
Get or set the number of minutes that the strategy will continue executing after market closes. |
|
Get or set the number of minutes that the strategy will start executing before the market opens. |
|
Get or set the current sleep time for the strategy. |
|
Returns the datetime of the last iteration. |
|
Returns the timezone of the data source. |
|
Returns the pytz object of the data source. |
|
Deprecated, will be removed in the future. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Caller-supplied backtest capital conversion and its provenance, or None. |
Live speed settings¶
Set these as class attributes on your strategy.
wake_iteration_on_fill(defaultFalse): in live trading, run the next trading iteration at once after an order fills instead of waiting outsleeptime. Only a fill that arrives while no iteration is running wakes it; a fill during a running iteration does not, and the next iteration starts aftersleeptimeas usual. Leave it off if the strategy places an order in every iteration.wake_iteration_on_partial_fill(defaultFalse): also wake on partial fills.
Quote and option chain reuse is set with environment variables, see Environment Variables. See Charles Schwab API Trading Bot in Python (LumiBot) (section “Fewer requests for scanners”).