Fix yearly resample timeframe

This commit is contained in:
Matthias
2024-01-23 07:22:18 +01:00
parent 6b78dac6f0
commit 48ea43f954
2 changed files with 3 additions and 0 deletions

View File

@@ -124,6 +124,8 @@ def timeframe_to_resample_freq(timeframe: str) -> str:
form ('1m', '5m', '1h', '1d', '1w', etc.) to the resample frequency form ('1m', '5m', '1h', '1d', '1w', etc.) to the resample frequency
used by pandas ('1T', '5T', '1H', '1D', '1W', etc.) used by pandas ('1T', '5T', '1H', '1D', '1W', etc.)
""" """
if timeframe == '1y':
return '1YS'
timeframe_seconds = timeframe_to_seconds(timeframe) timeframe_seconds = timeframe_to_seconds(timeframe)
timeframe_minutes = timeframe_seconds // 60 timeframe_minutes = timeframe_seconds // 60
resample_interval = f'{timeframe_seconds}s' resample_interval = f'{timeframe_seconds}s'

View File

@@ -133,6 +133,7 @@ def test_timeframe_to_msecs():
("1d", '86400s'), ("1d", '86400s'),
("1w", '604800s'), ("1w", '604800s'),
("1M", '1MS'), ("1M", '1MS'),
("1y", '1YS'),
]) ])
def test_timeframe_to_resample_freq(timeframe, expected): def test_timeframe_to_resample_freq(timeframe, expected):
assert timeframe_to_resample_freq(timeframe) == expected assert timeframe_to_resample_freq(timeframe) == expected