DefaultTradingStrategyUniverseModel#

tradeexecutor.strategy.trading_strategy_universe.DefaultTradingStrategyUniverseModel Python class in Trading Strategy framework.

class DefaultTradingStrategyUniverseModel[source]#

Bases: TradingStrategyUniverseModel

Shortcut for simple strategies.

  • Assumes we have a strategy that fits to tradeexecutor.strategy_module definiton

  • At the start of the backtests or at each cycle of live trading, call the create_trading_universe callback of the strategy

  • Validate the output of the function

__init__(client, execution_context, create_trading_universe)[source]#
Parameters:
  • candle_time_frame_override – Use this candle time bucket instead one given in the strategy file. Allows to “speedrun” strategies.

  • stop_loss_time_frame_override – Use this stop loss frequency instead one given in the strategy file. Allows to “speedrun” strategies.

  • client (Optional[BaseClient]) –

  • execution_context (ExecutionContext) –

  • create_trading_universe (Callable) –

Methods

__init__(client, execution_context, ...)

param candle_time_frame_override:

check_data_age(ts, universe, ...)

Check if our data is up-to-date and we do not have issues with feeds.

construct_universe(ts, mode, options)

On each strategy tick, refresh/recreate the trading universe for the strategy.

create_from_dataset(dataset, chains, ...[, ...])

Create an trading universe from dataset with zero filtering for the data.

load_data(time_frame, mode[, ...])

Loads the server-side data using the client.

log_universe(universe)

Log the state of the current universe.]

preload_universe(universe_options)

Triggered before backtesting execution.

__init__(client, execution_context, create_trading_universe)[source]#
Parameters:
  • candle_time_frame_override – Use this candle time bucket instead one given in the strategy file. Allows to “speedrun” strategies.

  • stop_loss_time_frame_override – Use this stop loss frequency instead one given in the strategy file. Allows to “speedrun” strategies.

  • client (Optional[BaseClient]) –

  • execution_context (ExecutionContext) –

  • create_trading_universe (Callable) –

preload_universe(universe_options)[source]#

Triggered before backtesting execution.

  • Load all datasets with progress bar display.

  • Not triggered in live trading, as universe changes between cycles

Parameters:

universe_options (UniverseOptions) –

construct_universe(ts, mode, options)[source]#

On each strategy tick, refresh/recreate the trading universe for the strategy.

This is called in mainloop before the strategy tick. It needs to download any data updates since the last tick.

Parameters:
  • mode (ExecutionMode) – Are we live trading or backtesting.

  • universe_options – Override any parameters for universe data. Most useful for making stop loss data checks less frequent, speeding up the backtesting.

  • ts (datetime) –

  • options (UniverseOptions) –

Return type:

TradingStrategyUniverse