diff --git a/freqtrade/exchange/exchange_utils.py b/freqtrade/exchange/exchange_utils.py index e71de992b..98e05bf7a 100644 --- a/freqtrade/exchange/exchange_utils.py +++ b/freqtrade/exchange/exchange_utils.py @@ -129,7 +129,9 @@ def timeframe_to_resample_freq(timeframe: str) -> str: timeframe_seconds = timeframe_to_seconds(timeframe) timeframe_minutes = timeframe_seconds // 60 resample_interval = f'{timeframe_seconds}s' - if timeframe_minutes >= 43200 and timeframe_minutes < 525600: + if 10000 < timeframe_minutes < 43200: + resample_interval = '1W-MON' + elif timeframe_minutes >= 43200 and timeframe_minutes < 525600: # Monthly candles need special treatment to stick to the 1st of the month resample_interval = f'{timeframe}S' elif timeframe_minutes > 43200: diff --git a/tests/conftest.py b/tests/conftest.py index 8ef40408d..c717f84ba 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -116,7 +116,7 @@ def generate_test_data(timeframe: str, size: int, start: str = '2020-07-05'): date = pd.date_range(start, periods=size, freq='1MS', tz='UTC') elif timeframe == '3M': date = pd.date_range(start, periods=size, freq='3MS', tz='UTC') - elif timeframe == '1w': + elif timeframe == '1w' or timeframe == '7d': date = pd.date_range(start, periods=size, freq='1W-MON', tz='UTC') else: tf_mins = timeframe_to_minutes(timeframe) diff --git a/tests/data/test_converter.py b/tests/data/test_converter.py index f6197a0f6..938370279 100644 --- a/tests/data/test_converter.py +++ b/tests/data/test_converter.py @@ -163,14 +163,15 @@ def test_ohlcv_to_dataframe_multi(timeframe): if timeframe in ('1M', '3M', '1y'): data1.loc[:, 'date'] = data1.loc[:, 'date'] + pd.to_timedelta('1w') else: + # Shift by half a timeframe data1.loc[:, 'date'] = data1.loc[:, 'date'] + (pd.to_timedelta(timeframe) / 2) df2 = ohlcv_to_dataframe(data1, timeframe, 'UNITTEST/USDT') assert len(df2) == len(data) - 1 tfs = timeframe_to_seconds(timeframe) tfm = timeframe_to_minutes(timeframe) - if 1 <= tfm < 43200: - # minute based resampling does not work on timeframes >= 1 month + if 1 <= tfm < 10000: + # minute based resampling does not work on timeframes >= 1 week ohlcv_dict = { 'open': 'first', 'high': 'max', diff --git a/tests/exchange/test_exchange_utils.py b/tests/exchange/test_exchange_utils.py index 4e56d4fcf..dd79bf083 100644 --- a/tests/exchange/test_exchange_utils.py +++ b/tests/exchange/test_exchange_utils.py @@ -131,7 +131,7 @@ def test_timeframe_to_msecs(): ("10m", '600s'), ("1h", '3600s'), ("1d", '86400s'), - ("1w", '604800s'), + ("1w", '1W-MON'), ("1M", '1MS'), ("1y", '1YS'), ])