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:

Strategy.cash

Returns the current cash.

Strategy.portfolio_value

Returns the last portfolio value (cash + positions value) reported by the broker.

Strategy.first_iteration

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).

Strategy.is_backtesting

Boolean flag indicating whether the strategy is running in backtesting mode.

Strategy.quote_asset

Returns the quote asset for the strategy.

Strategy.name

Returns the name of the strategy.

Strategy.initial_budget

Returns the initial budget for the strategy.

Strategy.minutes_before_closing

Get or set the number of minutes that the strategy will stop executing before market closes.

Strategy.minutes_before_opening

Get or set the number of minutes that the strategy will start executing before the market opens.

Strategy.sleeptime

Get or set the current sleep time for the strategy.

Strategy.last_on_trading_iteration_datetime

Returns the datetime of the last iteration.

Strategy.timezone

Returns the timezone of the data source.

Strategy.pytz

Returns the pytz object of the data source.

Strategy.unspent_money

Deprecated, will be removed in the future.