CycleDuration#
API documentation for tradeexecutor.strategy.cycle.CycleDuration Python class in Trading Strategy framework.
- 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__(*args, **kwds)#
Methods
Get the duration of the strategy cycle as Python timedelta object.
to_pandas_timedelta
()Convert to trading-strategy client format.
How many decision cycle periods a year has.
from_timebucket
(bucket)Convert from OHLCV time frame.
What's the base offset for this cycle.
Attributes
Run decide_trades() one second
Run decide_trades() every minute
Run decide_trades() every 5 minutes
Run decide_trades() every 15 minutes
Run decide_trades() every 30 minutes
Run decide_trades() every hour
Run decide_trades() every 2 hours
Run decide_trades() every 4 hours
Run decide_trades() every 6 hours
Run decide_trades() for every 8 hours
Run decide_trades() for every 10 hours
Run decide_trades() for every 12 hours
Run decide_trades() for every 16 hours
Run decide_trades() for every 24h hours
Run decide_trades() for every 2 days
Run decide_trades() for every 2 days
Run decide_trades() for every 4 days
Run decide_trades() for every week
Run decide_trades() for 2 weeks cycl
Run decide_trades() for 2 weeks cycl
Run decide_trades() for every month
Random cycle that's prime number in hours
Don't really know or care about the trade cycle duration.
Alias to match
TimeBucket
Alias to match
TimeBucket
Alias to match
TimeBucket
Alias to match
TimeBucket
Alias to match
TimeBucket
Alias to match
TimeBucket
Alias to match
TimeBucket
Alias
- cycle_1s = '1s'#
Run decide_trades() one second
Only used in unit testing. See strategies/test_only_/enzymy_end_to_end.py.
- 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_30m = '30m'#
Run decide_trades() every 30 minutes
- cycle_1h = '1h'#
Run decide_trades() every hour
- cycle_2h = '2h'#
Run decide_trades() every 2 hours
- cycle_4h = '4h'#
Run decide_trades() every 4 hours
- cycle_6h = '6h'#
Run decide_trades() every 6 hours
- cycle_8h = '8h'#
Run decide_trades() for every 8 hours
- cycle_10h = '10h'#
Run decide_trades() for every 10 hours
- cycle_12h = '12h'#
Run decide_trades() for every 12 hours
- cycle_16h = '16h'#
Run decide_trades() for every 16 hours
- cycle_1d = '1d'#
Run decide_trades() for every 24h hours
- cycle_2d = '2d'#
Run decide_trades() for every 2 days
- cycle_3d = '3d'#
Run decide_trades() for every 2 days
- cycle_4d = '4d'#
Run decide_trades() for every 4 days
- cycle_7d = '7d'#
Run decide_trades() for every week
- cycle_10d = '10d'#
Run decide_trades() for 2 weeks cycl
- cycle_14d = '14d'#
Run decide_trades() for 2 weeks cycl
- cycle_30d = '30d'#
Run decide_trades() for every month
- cycle_97h = '97h'#
Random cycle that’s prime number in 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.
- s1 = '1s'#
Alias to match
TimeBucket
- m1 = '1m'#
Alias to match
TimeBucket
- m15 = '15m'#
Alias to match
TimeBucket
- h1 = '1h'#
Alias to match
TimeBucket
- h4 = '4h'#
Alias to match
TimeBucket
- d1 = '1d'#
Alias to match
TimeBucket
- d7 = '7d'#
Alias to match
TimeBucket
- unknown = 'unknown'#
Alias
- to_timedelta()[source]#
Get the duration of the strategy cycle as Python timedelta object.
- Return type:
- 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:
- get_yearly_periods()[source]#
How many decision cycle periods a year has.
This metric is used to calculate Sharpe, other metrics.
See
tradeexecutor.analysis.advanced_metrics.calculate_advanced_metrics()
for more information.- Return type:
- static from_timebucket(bucket)[source]#
Convert from OHLCV time frame.
- Parameters:
bucket (TimeBucket) –
- Return type: