mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: don't auto-delete trades data due to invalid timerange
trades-data is already slow enough to download
This commit is contained in:
@@ -345,7 +345,7 @@ def refresh_backtest_ohlcv_data(
|
|||||||
progress.update(timeframe_task, completed=0)
|
progress.update(timeframe_task, completed=0)
|
||||||
|
|
||||||
if pair not in exchange.markets:
|
if pair not in exchange.markets:
|
||||||
pairs_not_available.append(pair)
|
pairs_not_available.append(f"{pair}: Pair not available on exchange.")
|
||||||
logger.info(f"Skipping pair {pair}...")
|
logger.info(f"Skipping pair {pair}...")
|
||||||
continue
|
continue
|
||||||
for timeframe in timeframes:
|
for timeframe in timeframes:
|
||||||
@@ -411,7 +411,6 @@ def _download_trades_history(
|
|||||||
Download trade history from the exchange.
|
Download trade history from the exchange.
|
||||||
Appends to previously downloaded trades data.
|
Appends to previously downloaded trades data.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
until = None
|
until = None
|
||||||
since = 0
|
since = 0
|
||||||
if timerange:
|
if timerange:
|
||||||
@@ -428,11 +427,11 @@ def _download_trades_history(
|
|||||||
|
|
||||||
if not trades.empty and since > 0 and since < trades.iloc[0]["timestamp"]:
|
if not trades.empty and since > 0 and since < trades.iloc[0]["timestamp"]:
|
||||||
# since is before the first trade
|
# since is before the first trade
|
||||||
logger.info(
|
raise ValueError(
|
||||||
f"Start ({trades.iloc[0]['date']:{DATETIME_PRINT_FORMAT}}) earlier than "
|
f"Start {format_ms_time(since)} earlier than "
|
||||||
f"available data. Redownloading trades for {pair}..."
|
f"available data ({trades.iloc[0]['date']:{DATETIME_PRINT_FORMAT}}). "
|
||||||
|
f"Please use `--erase` if you'd like to redownload {pair}."
|
||||||
)
|
)
|
||||||
trades = trades_list_to_df([])
|
|
||||||
|
|
||||||
from_id = trades.iloc[-1]["id"] if not trades.empty else None
|
from_id = trades.iloc[-1]["id"] if not trades.empty else None
|
||||||
if not trades.empty and since < trades.iloc[-1]["timestamp"]:
|
if not trades.empty and since < trades.iloc[-1]["timestamp"]:
|
||||||
@@ -481,10 +480,6 @@ def _download_trades_history(
|
|||||||
logger.info(f"New Amount of trades: {len(trades)}")
|
logger.info(f"New Amount of trades: {len(trades)}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception:
|
|
||||||
logger.exception(f'Failed to download and store historic trades for pair: "{pair}". ')
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def refresh_backtest_trades_data(
|
def refresh_backtest_trades_data(
|
||||||
exchange: Exchange,
|
exchange: Exchange,
|
||||||
@@ -508,7 +503,7 @@ def refresh_backtest_trades_data(
|
|||||||
for pair in pairs:
|
for pair in pairs:
|
||||||
progress.update(pair_task, description=f"Downloading trades [{pair}]")
|
progress.update(pair_task, description=f"Downloading trades [{pair}]")
|
||||||
if pair not in exchange.markets:
|
if pair not in exchange.markets:
|
||||||
pairs_not_available.append(pair)
|
pairs_not_available.append(f"{pair}: Pair not available on exchange.")
|
||||||
logger.info(f"Skipping pair {pair}...")
|
logger.info(f"Skipping pair {pair}...")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -517,6 +512,7 @@ def refresh_backtest_trades_data(
|
|||||||
logger.info(f"Deleting existing data for pair {pair}.")
|
logger.info(f"Deleting existing data for pair {pair}.")
|
||||||
|
|
||||||
logger.info(f"Downloading trades for pair {pair}.")
|
logger.info(f"Downloading trades for pair {pair}.")
|
||||||
|
try:
|
||||||
_download_trades_history(
|
_download_trades_history(
|
||||||
exchange=exchange,
|
exchange=exchange,
|
||||||
pair=pair,
|
pair=pair,
|
||||||
@@ -525,6 +521,13 @@ def refresh_backtest_trades_data(
|
|||||||
data_handler=data_handler,
|
data_handler=data_handler,
|
||||||
trading_mode=trading_mode,
|
trading_mode=trading_mode,
|
||||||
)
|
)
|
||||||
|
except ValueError as e:
|
||||||
|
pairs_not_available.append(f"{pair}: {str(e)}")
|
||||||
|
except Exception:
|
||||||
|
logger.exception(
|
||||||
|
f'Failed to download and store historic trades for pair: "{pair}". '
|
||||||
|
)
|
||||||
|
|
||||||
progress.update(pair_task, advance=1)
|
progress.update(pair_task, advance=1)
|
||||||
|
|
||||||
return pairs_not_available
|
return pairs_not_available
|
||||||
@@ -674,7 +677,7 @@ def download_data_main(config: Config) -> None:
|
|||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
if pairs_not_available:
|
if pairs_not_available:
|
||||||
logger.info(
|
logger.warning(
|
||||||
f"Pairs [{','.join(pairs_not_available)}] not available "
|
f"Encountered a problem downloading the following pairs from {exchange.name}: \n"
|
||||||
f"on exchange {exchange.name}."
|
f"{'\n'.join(pairs_not_available)}"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user