From 8069cd66898653b9d9ab98ae44679c19df3fa1b6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 27 Aug 2019 07:13:50 +0200 Subject: [PATCH] add refresh_trades_ method --- freqtrade/data/history.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/freqtrade/data/history.py b/freqtrade/data/history.py index f5a1527f8..2056ef1c5 100644 --- a/freqtrade/data/history.py +++ b/freqtrade/data/history.py @@ -332,7 +332,6 @@ def refresh_backtest_ohlcv_data(exchange: Exchange, pairs: List[str], timeframes def download_trades_history(datadir: Optional[Path], exchange: Optional[Exchange], pair: str, - ticker_interval: str = '5m', timerange: Optional[TimeRange] = None) -> bool: """ Download trade history from the exchange. @@ -374,6 +373,35 @@ def download_trades_history(datadir: Optional[Path], return False +def refresh_backtest_trades_data(exchange: Exchange, pairs: List[str], timeframes: List[str], + dl_path: Path, timerange: TimeRange, + erase=False) -> List[str]: + """ + Refresh stored trades data . + Used by freqtrade download-data + :return: Pairs not available + """ + pairs_not_available = [] + for pair in pairs: + if pair not in exchange.markets: + pairs_not_available.append(pair) + logger.info(f"Skipping pair {pair}...") + continue + # for ticker_interval in timeframes: + + dl_file = pair_trades_filename(dl_path, pair) + if erase and dl_file.exists(): + logger.info( + f'Deleting existing data for pair {pair}.') + dl_file.unlink() + + logger.info(f'Downloading trades for pair {pair}.') + download_trades_history(datadir=dl_path, exchange=exchange, + pair=pair, + timerange=timerange) + return pairs_not_available + + def get_timeframe(data: Dict[str, DataFrame]) -> Tuple[arrow.Arrow, arrow.Arrow]: """ Get the maximum timeframe for the given backtest data