BacktestSetup#
API documentation for tradeexecutor.backtest.backtest_runner.BacktestSetup Python class in Trading Strategy framework.
- class BacktestSetup[source]#
Bases:
object
Describe backtest setup, ready to run.
- __init__(start_at, end_at, universe_options, cycle_duration, universe, wallet, state, pricing_model, routing_model, execution_model, sync_model, trading_strategy_engine_version, trade_routing, reserve_currency, decide_trades, create_trading_universe, create_indicators=None, indicator_combinations=None, indicator_storage=None, data_preload=True, name='backtest', minimum_data_lookback_range=None, pair_configurator=None, parameters=None, grid_search=False, mode=ExecutionMode.backtesting, max_workers=8)#
- Parameters:
start_at (datetime.datetime | None) –
end_at (datetime.datetime | None) –
universe_options (UniverseOptions) –
cycle_duration (Optional[CycleDuration]) –
universe (Optional[TradingStrategyUniverse]) –
wallet (SimulatedWallet) –
state (State) –
pricing_model (Optional[BacktestPricing]) –
routing_model (Optional[BacktestRoutingModel]) –
execution_model (BacktestExecution) –
sync_model (BacktestSyncModel) –
trading_strategy_engine_version (str) –
trade_routing (TradeRouting) –
reserve_currency (ReserveCurrency) –
decide_trades (DecideTradesProtocol) –
create_trading_universe (Optional[CreateTradingUniverseProtocol]) –
create_indicators (Optional[CreateIndicatorsProtocolV1]) –
indicator_combinations (Optional[set[tradeexecutor.strategy.pandas_trader.indicator.IndicatorKey]]) –
indicator_storage (Optional[DiskIndicatorStorage]) –
data_preload (bool) –
name (str) –
pair_configurator (Optional[EthereumBacktestPairConfigurator]) –
parameters (tradeexecutor.strategy.parameters.StrategyParameters | None) –
grid_search (bool) –
mode (ExecutionMode) –
max_workers (int) –
- Return type:
None
Methods
__init__
(start_at, end_at, universe_options, ...)Create a strategy description and runner based on backtest parameters in this setup.
Load indicators for this backtest.
prepare_indicators
(execution_context)Prepare indicators for this backtest run.
Attributes
create_indicators
data_preload
Is this backtest part a grid saerch
indicator_combinations
indicator_storage
How many workers to use for indicator calculation
minimum_data_lookback_range
What's the execution mode of this backtest run
Name for this backtest
pair_configurator
Backtest/grid parameters
Test start
Test end
Override trading_strategy_cycle from strategy module
Override trading_strategy_cycle from strategy module
universe
wallet
state
pricing_model
routing_model
execution_model
sync_model
trading_strategy_engine_version
trade_routing
reserve_currency
decide_trades
create_trading_universe
- start_at: datetime.datetime | None#
Test start
Legacy. Use UniverseOptions.
- end_at: datetime.datetime | None#
Test end
Legacy. Use UniverseOptions.
- universe_options: UniverseOptions#
Override trading_strategy_cycle from strategy module
- cycle_duration: Optional[CycleDuration]#
Override trading_strategy_cycle from strategy module
- parameters: tradeexecutor.strategy.parameters.StrategyParameters | None = None#
Backtest/grid parameters
When trading_strategy_engine_version >= 0.4
- mode: ExecutionMode = 'backtesting'#
What’s the execution mode of this backtest run
- backtest_static_universe_strategy_factory(*ignore, execution_model, execution_context, sync_model, pricing_model_factory, valuation_model_factory, client, timed_task_context_manager, approval_model, **kwargs)[source]#
Create a strategy description and runner based on backtest parameters in this setup.
- Parameters:
execution_model (BacktestExecution) –
execution_context (ExecutionContext) –
sync_model (BacktestSyncModel) –
pricing_model_factory (Callable) –
valuation_model_factory (Callable) –
client (Client) –
timed_task_context_manager (AbstractContextManager) –
approval_model (ApprovalModel) –
- Return type:
- prepare_indicators(execution_context)[source]#
Prepare indicators for this backtest run.
Calculate and cache the indicator results
Display TQDM progress bar about reading cached results and calculating new indicators
- Parameters:
execution_context (ExecutionContext) –
- Return type:
- load_indicators()[source]#
Load indicators for this backtest.
Applies for grid search execution path
All indicators must be precalculated in cache warm up
- Return type:
- __init__(start_at, end_at, universe_options, cycle_duration, universe, wallet, state, pricing_model, routing_model, execution_model, sync_model, trading_strategy_engine_version, trade_routing, reserve_currency, decide_trades, create_trading_universe, create_indicators=None, indicator_combinations=None, indicator_storage=None, data_preload=True, name='backtest', minimum_data_lookback_range=None, pair_configurator=None, parameters=None, grid_search=False, mode=ExecutionMode.backtesting, max_workers=8)#
- Parameters:
start_at (datetime.datetime | None) –
end_at (datetime.datetime | None) –
universe_options (UniverseOptions) –
cycle_duration (Optional[CycleDuration]) –
universe (Optional[TradingStrategyUniverse]) –
wallet (SimulatedWallet) –
state (State) –
pricing_model (Optional[BacktestPricing]) –
routing_model (Optional[BacktestRoutingModel]) –
execution_model (BacktestExecution) –
sync_model (BacktestSyncModel) –
trading_strategy_engine_version (str) –
trade_routing (TradeRouting) –
reserve_currency (ReserveCurrency) –
decide_trades (DecideTradesProtocol) –
create_trading_universe (Optional[CreateTradingUniverseProtocol]) –
create_indicators (Optional[CreateIndicatorsProtocolV1]) –
indicator_combinations (Optional[set[tradeexecutor.strategy.pandas_trader.indicator.IndicatorKey]]) –
indicator_storage (Optional[DiskIndicatorStorage]) –
data_preload (bool) –
name (str) –
pair_configurator (Optional[EthereumBacktestPairConfigurator]) –
parameters (tradeexecutor.strategy.parameters.StrategyParameters | None) –
grid_search (bool) –
mode (ExecutionMode) –
max_workers (int) –
- Return type:
None