mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Prepare converter to work on 1s data.
This commit is contained in:
@@ -84,7 +84,7 @@ def ohlcv_fill_up_missing_data(dataframe: DataFrame, timeframe: str, pair: str)
|
|||||||
using the previous close as price for "open", "high" "low" and "close", volume is set to 0
|
using the previous close as price for "open", "high" "low" and "close", volume is set to 0
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from freqtrade.exchange import timeframe_to_minutes
|
from freqtrade.exchange import timeframe_to_seconds
|
||||||
|
|
||||||
ohlcv_dict = {
|
ohlcv_dict = {
|
||||||
'open': 'first',
|
'open': 'first',
|
||||||
@@ -93,8 +93,9 @@ def ohlcv_fill_up_missing_data(dataframe: DataFrame, timeframe: str, pair: str)
|
|||||||
'close': 'last',
|
'close': 'last',
|
||||||
'volume': 'sum'
|
'volume': 'sum'
|
||||||
}
|
}
|
||||||
timeframe_minutes = timeframe_to_minutes(timeframe)
|
timeframe_seconds = timeframe_to_seconds(timeframe)
|
||||||
resample_interval = f'{timeframe_minutes}min'
|
timeframe_minutes = timeframe_seconds // 60
|
||||||
|
resample_interval = f'{timeframe_seconds}s'
|
||||||
if timeframe_minutes >= 43200 and timeframe_minutes < 525600:
|
if timeframe_minutes >= 43200 and timeframe_minutes < 525600:
|
||||||
# Monthly candles need special treatment to stick to the 1st of the month
|
# Monthly candles need special treatment to stick to the 1st of the month
|
||||||
resample_interval = f'{timeframe}S'
|
resample_interval = f'{timeframe}S'
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ def test_ohlcv_fill_up_missing_data2(caplog):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('timeframe', [
|
@pytest.mark.parametrize('timeframe', [
|
||||||
'1m', '5m', '15m', '1h', '2h', '4h', '8h', '12h', '1d', '7d', '1w', '1M', '3M', '1y'
|
'1s', '1m', '5m', '15m', '1h', '2h', '4h', '8h', '12h', '1d', '7d', '1w', '1M', '3M', '1y'
|
||||||
])
|
])
|
||||||
def test_ohlcv_to_dataframe_multi(timeframe):
|
def test_ohlcv_to_dataframe_multi(timeframe):
|
||||||
data = generate_test_data(timeframe, 180)
|
data = generate_test_data(timeframe, 180)
|
||||||
@@ -151,8 +151,8 @@ def test_ohlcv_to_dataframe_multi(timeframe):
|
|||||||
assert len(df2) == len(data) - 1
|
assert len(df2) == len(data) - 1
|
||||||
tfs = timeframe_to_seconds(timeframe)
|
tfs = timeframe_to_seconds(timeframe)
|
||||||
tfm = timeframe_to_minutes(timeframe)
|
tfm = timeframe_to_minutes(timeframe)
|
||||||
if tfm < 43200:
|
if 1 <= tfm < 43200:
|
||||||
# minute based resampling does not work on timefrmaes > 1 week
|
# minute based resampling does not work on timeframes > 1 week
|
||||||
ohlcv_dict = {
|
ohlcv_dict = {
|
||||||
'open': 'first',
|
'open': 'first',
|
||||||
'high': 'max',
|
'high': 'max',
|
||||||
|
|||||||
Reference in New Issue
Block a user