UniverseModel#

tradeexecutor.strategy.universe_model.UniverseModel class.

class UniverseModel[source]#

Bases: ABC

Create and manage trade universe.

On a live execution, the trade universe is reconstructor for the every tick, by refreshing the trading data from the server.

__init__()#

Methods

__init__()

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)

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

preload_universe()

Triggered before backtesting execution.

preload_universe()[source]#

Triggered before backtesting execution.

  • Load all datasets with progress bar display

  • Data is saved in FS cache

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

abstract construct_universe(ts, mode)[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
Return type

StrategyExecutionUniverse

check_data_age(ts, universe, best_before_duration)[source]#

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

Ensure we do not try to execute live trades with stale data.

Raises

DataTooOld – in the case data is too old to execute.

Parameters