Implement startup-period to default-strategy
This commit is contained in:
parent
704121c197
commit
6382a4cd04
@ -421,7 +421,6 @@ class Backtesting:
|
|||||||
timerange = TimeRange.parse_timerange(None if self.config.get(
|
timerange = TimeRange.parse_timerange(None if self.config.get(
|
||||||
'timerange') is None else str(self.config.get('timerange')))
|
'timerange') is None else str(self.config.get('timerange')))
|
||||||
|
|
||||||
|
|
||||||
data = history.load_data(
|
data = history.load_data(
|
||||||
datadir=Path(self.config['datadir']),
|
datadir=Path(self.config['datadir']),
|
||||||
pairs=pairs,
|
pairs=pairs,
|
||||||
@ -447,9 +446,11 @@ class Backtesting:
|
|||||||
'Loading backtest data from %s up to %s (%s days)..',
|
'Loading backtest data from %s up to %s (%s days)..',
|
||||||
min_date.isoformat(), max_date.isoformat(), (max_date - min_date).days
|
min_date.isoformat(), max_date.isoformat(), (max_date - min_date).days
|
||||||
)
|
)
|
||||||
if not timerange.starttype:
|
if (not timerange.starttype or (self.required_startup
|
||||||
# If no startts was defined, we need to move the backtesting start
|
and min_date.timestamp == timerange.startts)):
|
||||||
logger.info("Moving start-date by %s candles.", self.required_startup)
|
# If no startts was defined, or test-data starts at the defined test-date
|
||||||
|
logger.warning("Moving start-date by %s candles to account for startup time.",
|
||||||
|
self.required_startup)
|
||||||
timerange.startts = (min_date.timestamp
|
timerange.startts = (min_date.timestamp
|
||||||
+ timeframe_to_seconds(self.ticker_interval)
|
+ timeframe_to_seconds(self.ticker_interval)
|
||||||
* self.required_startup)
|
* self.required_startup)
|
||||||
|
@ -39,6 +39,9 @@ class DefaultStrategy(IStrategy):
|
|||||||
'stoploss_on_exchange': False
|
'stoploss_on_exchange': False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Count of candles the strategy requires before producing valid signals
|
||||||
|
startup_candle_count: int = 20
|
||||||
|
|
||||||
# Optional time in force for orders
|
# Optional time in force for orders
|
||||||
order_time_in_force = {
|
order_time_in_force = {
|
||||||
'buy': 'gtc',
|
'buy': 'gtc',
|
||||||
@ -105,9 +108,6 @@ class DefaultStrategy(IStrategy):
|
|||||||
# EMA - Exponential Moving Average
|
# EMA - Exponential Moving Average
|
||||||
dataframe['ema10'] = ta.EMA(dataframe, timeperiod=10)
|
dataframe['ema10'] = ta.EMA(dataframe, timeperiod=10)
|
||||||
|
|
||||||
# SMA - Simple Moving Average
|
|
||||||
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
|
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
@ -838,7 +838,10 @@ def test_backtest_start_timerange(default_conf, mocker, caplog, testdatadir):
|
|||||||
f'Using data directory: {testdatadir} ...',
|
f'Using data directory: {testdatadir} ...',
|
||||||
'Using stake_currency: BTC ...',
|
'Using stake_currency: BTC ...',
|
||||||
'Using stake_amount: 0.001 ...',
|
'Using stake_amount: 0.001 ...',
|
||||||
'Backtesting with data from 2017-11-14T21:17:00+00:00 '
|
'Backtesting with data from 2017-11-14T21:37:00+00:00 '
|
||||||
|
'up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
||||||
|
'Moving start-date by 20 candles to account for startup time.',
|
||||||
|
'Loading backtest data from 2017-11-14T21:17:00+00:00 '
|
||||||
'up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
'up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
||||||
'Parameter --enable-position-stacking detected ...'
|
'Parameter --enable-position-stacking detected ...'
|
||||||
]
|
]
|
||||||
@ -892,7 +895,10 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir):
|
|||||||
f'Using data directory: {testdatadir} ...',
|
f'Using data directory: {testdatadir} ...',
|
||||||
'Using stake_currency: BTC ...',
|
'Using stake_currency: BTC ...',
|
||||||
'Using stake_amount: 0.001 ...',
|
'Using stake_amount: 0.001 ...',
|
||||||
'Backtesting with data from 2017-11-14T21:17:00+00:00 '
|
'Backtesting with data from 2017-11-14T21:37:00+00:00 '
|
||||||
|
'up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
||||||
|
'Moving start-date by 20 candles to account for startup time.',
|
||||||
|
'Loading backtest data from 2017-11-14T21:17:00+00:00 '
|
||||||
'up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
'up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
||||||
'Parameter --enable-position-stacking detected ...',
|
'Parameter --enable-position-stacking detected ...',
|
||||||
'Running backtesting for Strategy DefaultStrategy',
|
'Running backtesting for Strategy DefaultStrategy',
|
||||||
|
Loading…
Reference in New Issue
Block a user