ExecutionMode#

API documentation for tradeexecutor.strategy.execution_context.ExecutionMode Python class in Trading Strategy framework.

class ExecutionMode[source]#

Bases: Enum

Different execution modes the strategy engine can handle.

Depending on how we are using the engine, we might enable and disable additional checks and features.

  • In unit testing execution mode we can skip all kind of delays when we need to wait a blockchain chain tip to stabilise

  • In backtesting execution mode we skip calculation of statistics between strategy decision cycles, as these statistics are discarted and calculations slows us down

__init__(*args, **kwds)#

Methods

is_live_trading()

Are we trading real time?

is_backtesting()

The strategy is running for backtesting.

is_fresh_data_always_needed()

Should we purge caches for each trade cycle.

is_unit_testing()

Are we executing unit tests.

Attributes

real_trading

We are live trading with real assets

paper_trading

We are live trading with mock assets

backtesting

We are backtesting When backtesting mode is selected, we can skip most of the statistical calculations that would otherwise be calculated during live-trade.

data_research

We are doing data research.

data_preload

We are loading and caching datasets before a backtesting session can begin.

unit_testing

Internal unit testing of modules

unit_testing_trading

We are operating on real datasets like real_trading but we do not want to purge caches.

simulated_trading

Simulated trading: Blockchain we are connected is not real.

preflight_check

Prefilight checks

one_off

One off diagnostic and scripts

real_trading = 'real_trading'#

We are live trading with real assets

paper_trading = 'paper_trading'#

We are live trading with mock assets

TODO: This mode is not yet supported

backtesting = 'backtesting'#

We are backtesting When backtesting mode is selected, we can skip most of the statistical calculations that would otherwise be calculated during live-trade. This offers great performance benefits for backtesting.

data_research = 'data_research'#

We are doing data research.

There is not going to be any trading, we are only interested in datsets.

data_preload = 'data_preload'#

We are loading and caching datasets before a backtesting session can begin. We call create_trading_universe() and assume tradingstrategy.client.Client class is set to a such state it can display nice progress bar when loading data in a Jupyter notebook.

unit_testing = 'unit_Testing'#

Internal unit testing of modules

This specifically refers to unit testing that uses backtesting data. See unit_testing_trading as well.

unit_testing_trading = 'unit_testing_trading'#

We are operating on real datasets like real_trading but we do not want to purge caches.

This mode is specially used to test some live trading features.

simulated_trading = 'simulated_trading'#

Simulated trading: Blockchain we are connected is not real.

We are trading against a simulated step-by-step blockchain like EthereumTester. This allows us to control block production, but otherwise behave as live trading.

In this mode, we are also not using any dataset loading features, but the trading universe and price feeds are typed in the test code.

preflight_check = 'preflight_check'#

Prefilight checks

In this execution mode, we are invoked from the command line to check that all of our files and connections are intact.

one_off = 'one_off'#

One off diagnostic and scripts

Used in the interactive :ref:`console. and debugging scripts.

is_live_trading()[source]#

Are we trading real time?

  • For live trading, we are operating on real-time price feeds based on required_history_period distance, instead of explicit start and end dates of backtesting

  • Preflight check is considered live trading, because strategy modules are not in backtesting when doing preflight checks

Return type:

bool

is_backtesting()[source]#

The strategy is running for backtesting.

Return type:

bool

is_fresh_data_always_needed()[source]#

Should we purge caches for each trade cycle.

This will force the redownload of data on each cycle.

is_unit_testing()[source]#

Are we executing unit tests.

Return type:

bool