CycleDuration#

tradeexecutor.strategy.cycle.CycleDuration class.

class CycleDuration[source]#

Bases: Enum

Strategy cycle duration options.

This enum defines what strategy cycle durations backtesting and live testing engine supports.

It is also the value you can enter as trading_strategy_cycle option for your strategies.

All cycles are aligned to the wall clock time. E.g. 24h cycle is always run at 00:00.

See Strategy cycle for more information.

__init__()#

Methods

to_timedelta()

Get the duration of the strategy cycle as Python timedelta object.

to_timebucket()

Convert to trading-strategy client format.

from_timebucket(bucket)

Convert from OHLCV time frame.

Attributes

cycle_1m

Run decide_trades() every minute

cycle_5m

Run decide_trades() every 5 minutes

cycle_15m

Run decide_trades() every 15 minutes

cycle_1h

Run decide_trades() every hour

cycle_4h

Run decide_trades() every 4 hours

cycle_8h

Run decide_trades() for every 8 hours

cycle_16h

Run decide_trades() for every 16 hours

cycle_1d

Run decide_trades() for every 24h hours

cycle_unknown

Don't really know or care about the trade cycle duration.

cycle_1m = '1m'#

Run decide_trades() every minute

cycle_5m = '5m'#

Run decide_trades() every 5 minutes

cycle_15m = '15m'#

Run decide_trades() every 15 minutes

cycle_1h = '1h'#

Run decide_trades() every hour

cycle_4h = '4h'#

Run decide_trades() every 4 hours

cycle_8h = '8h'#

Run decide_trades() for every 8 hours

cycle_16h = '16h'#

Run decide_trades() for every 16 hours

cycle_1d = '1d'#

Run decide_trades() for every 24h hours

cycle_unknown = 'unknown'#

Don’t really know or care about the trade cycle duration.

Used when doing a simulated execution loop with set_up_simulated_execution_loop and where the time is ticked through manually by producing new blocks with EthereumTester chain.

to_timedelta()[source]#

Get the duration of the strategy cycle as Python timedelta object.

Return type

timedelta

to_timebucket()[source]#

Convert to trading-strategy client format.

TODO: Try to avoid tightly coupling and leaking trading-strategy client here.

Unlike TimeBucket, CycleDuration may have “unknown” value that is presented by None

Return type

Optional[TimeBucket]

static from_timebucket(bucket)[source]#

Convert from OHLCV time frame.

Parameters

bucket (TimeBucket) –

Return type

Optional[CycleDuration]