StrategyModuleInformation#

API documentation for tradeexecutor.strategy.strategy_module.StrategyModuleInformation Python class in Trading Strategy framework.

class StrategyModuleInformation[source]#

Bases: object

Describe elements that we need to have in a strategy module.

The class variables are the same name as found in the Python strategy module. They can be uppercase or lowercase - all strategy module variables are exported as lowercase.

__init__(path, source_code, trading_strategy_engine_version, trading_strategy_type, trading_strategy_cycle, decide_trades, create_trading_universe, trade_routing=None, chain_id=None, reserve_currency=None, backtest_start=None, backtest_end=None, initial_cash=None, name=None, short_description=None, long_description=None, icon=None, tags=None)#
Parameters:
Return type:

None

Methods

__init__(path, source_code, ...[, ...])

get_universe_options()

What backtest range this strategy defaults to

is_version_greater_or_equal_than(major, ...)

Check strategy module for its version compatibility.

validate()

Check that the user inputted variable names look good.

validate_backtest()

Validate that the module is backtest runnable.

Attributes

backtest_end

Only needed for backtests

backtest_start

Only needed for backtests

chain_id

Blockchain id on which this strategy operates

icon

Strategy icon

initial_cash

Only needed for backtests

long_description

Strategy long description

name

Strategy name

reserve_currency

What currency we use for the strategy.

short_description

Strategy short description

tags

Any tags on the strategy.

trade_routing

Routing hinting.

path

Path to the module

source_code

The source code of the strategy

trading_strategy_engine_version

The engine version this strategy requires.

trading_strategy_type

Enable different strategy scripts.

trading_strategy_cycle

decide_trades

create_trading_universe

If execution_context.live_trading is true then this function is called for every execution cycle.

path: Path#

Path to the module

source_code: Optional[str]#

The source code of the strategy

Can be set None for strategies that are not public.

trading_strategy_engine_version: str#

The engine version this strategy requires.

Function signatures and results may be changed depending on for engine version the strategy is for.

See SUPPORTED_TRADING_STRATEGY_ENGINE_VERSIONS.

trading_strategy_type: StrategyType#

Enable different strategy scripts.

If not set default to StrategyType.managed_positions.

create_trading_universe: CreateTradingUniverseProtocol#

If execution_context.live_trading is true then this function is called for every execution cycle. If we are backtesting, then this function is called only once at the start of backtesting and the decide_trades need to deal with new and deprecated trading pairs.

trade_routing: Optional[TradeRouting] = None#

Routing hinting.

Legacy option: most strategies can set this in create_trading_universe(). Default to TradeRouting.default.

chain_id: Optional[ChainId] = None#

Blockchain id on which this strategy operates

Valid for single chain strategies only

reserve_currency: Optional[ReserveCurrency] = None#

What currency we use for the strategy.

Can be left out in new versions and is set in create_trading_universe()

backtest_start: Optional[datetime] = None#

Only needed for backtests

backtest_end: Optional[datetime] = None#

Only needed for backtests

initial_cash: Optional[float] = None#

Only needed for backtests

name: Optional[str] = None#

Strategy name

Note that this must be also separately configured in the frontend user interface, as name is used before the strategy metadata is loaded.

short_description: Optional[str] = None#

Strategy short description

1 sentence description

long_description: Optional[str] = None#

Strategy long description

Two paragraph description, may contain HTML.

icon: Optional[str] = None#

Strategy icon

Two paragraph description, may contain HTML.

tags: Optional[Set[StrategyTag]] = None#

Any tags on the strategy.

Set for tags attribute of a strategy module.

is_version_greater_or_equal_than(major, minor, patch)[source]#

Check strategy module for its version compatibility.

Parameters:
  • major (int) –

  • minor (int) –

  • patch (int) –

Return type:

bool

validate()[source]#

Check that the user inputted variable names look good.

Raises:

StrategyModuleNotValid – If we could not load/parse strategy module for some reason

validate_backtest()[source]#

Validate that the module is backtest runnable.

get_universe_options()[source]#

What backtest range this strategy defaults to

Return type:

UniverseOptions

__init__(path, source_code, trading_strategy_engine_version, trading_strategy_type, trading_strategy_cycle, decide_trades, create_trading_universe, trade_routing=None, chain_id=None, reserve_currency=None, backtest_start=None, backtest_end=None, initial_cash=None, name=None, short_description=None, long_description=None, icon=None, tags=None)#
Parameters:
Return type:

None