feat: don't force-redownload all data

If the given timerange starts prior to the available data,
the bot shouldn't force-download everything unless forced via `--erase`
or via `--prepend`.
This commit is contained in:
Matthias
2024-11-16 12:58:23 +01:00
parent 68712c884e
commit d66381863e

View File

@@ -8,7 +8,6 @@ from pandas import DataFrame, concat
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import ( from freqtrade.constants import (
DATETIME_PRINT_FORMAT, DATETIME_PRINT_FORMAT,
DEFAULT_DATAFRAME_COLUMNS,
DL_DATA_TIMEFRAMES, DL_DATA_TIMEFRAMES,
DOCS_LINK, DOCS_LINK,
Config, Config,
@@ -199,14 +198,20 @@ def _load_cached_data_for_updating(
candle_type=candle_type, candle_type=candle_type,
) )
if not data.empty: if not data.empty:
if not prepend and start and start < data.iloc[0]["date"]: if prepend:
# Earlier data than existing data requested, redownload all end = data.iloc[0]["date"]
data = DataFrame(columns=DEFAULT_DATAFRAME_COLUMNS)
else: else:
if prepend: if start and start < data.iloc[0]["date"]:
end = data.iloc[0]["date"] # Earlier data than existing data requested, Update start date
else: logger.info(
start = data.iloc[-1]["date"] f"{pair}, {timeframe}, {candle_type}: "
f"Start {start:{DATETIME_PRINT_FORMAT}} earlier than available data start. "
f"Please use `--prepend` to download data prior "
f"to {data.iloc[0]['date']:{DATETIME_PRINT_FORMAT}}, or "
"`--erase` to redownload all data."
)
start = data.iloc[-1]["date"]
start_ms = int(start.timestamp() * 1000) if start else None start_ms = int(start.timestamp() * 1000) if start else None
end_ms = int(end.timestamp() * 1000) if end else None end_ms = int(end.timestamp() * 1000) if end else None
return data, start_ms, end_ms return data, start_ms, end_ms