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:
Return type:

None

Methods

__init__(start_at, end_at, universe_options, ...)

backtest_static_universe_strategy_factory(...)

Create a strategy description and runner based on backtest parameters in this setup.

load_indicators()

Load indicators for this backtest.

prepare_indicators(execution_context)

Prepare indicators for this backtest run.

Attributes

create_indicators

data_preload

grid_search

Is this backtest part a grid saerch

indicator_combinations

indicator_storage

max_workers

How many workers to use for indicator calculation

minimum_data_lookback_range

mode

What's the execution mode of this backtest run

name

Name for this backtest

pair_configurator

parameters

Backtest/grid parameters

start_at

Test start

end_at

Test end

universe_options

Override trading_strategy_cycle from strategy module

cycle_duration

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

name: str = 'backtest'#

Name for this backtest

parameters: tradeexecutor.strategy.parameters.StrategyParameters | None = None#

Backtest/grid parameters

When trading_strategy_engine_version >= 0.4

Is this backtest part a grid saerch

mode: ExecutionMode = 'backtesting'#

What’s the execution mode of this backtest run

max_workers: int = 8#

How many workers to use for indicator calculation

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:
Return type:

StrategyExecutionDescription

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:

StrategyInputIndicators

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:

StrategyInputIndicators

__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:
Return type:

None