From 76187d31cf55a23061a1b558dc1696707616a602 Mon Sep 17 00:00:00 2001 From: Meng Xiangzhuo Date: Sat, 2 Nov 2024 04:02:43 +0800 Subject: [PATCH] feat: more binance fast download timeframes --- freqtrade/exchange/binance.py | 4 +++- freqtrade/exchange/binance_public_data.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/freqtrade/exchange/binance.py b/freqtrade/exchange/binance.py index 5e3588b23..44906273f 100644 --- a/freqtrade/exchange/binance.py +++ b/freqtrade/exchange/binance.py @@ -134,7 +134,9 @@ class Binance(Exchange): ) return DataFrame(columns=DEFAULT_DATAFRAME_COLUMNS) - if timeframe in ["1s", "1m", "5m"] and candle_type in [CandleType.SPOT, CandleType.FUTURES]: + if (candle_type == CandleType.SPOT and timeframe in ["1s", "1m", "3m", "5m"]) or ( + candle_type == CandleType.FUTURES and timeframe in ["1m", "3m", "5m", "15m", "30m"] + ): df = self.loop.run_until_complete( binance_public_data.fetch_ohlcv( candle_type=candle_type, diff --git a/freqtrade/exchange/binance_public_data.py b/freqtrade/exchange/binance_public_data.py index bbe652feb..1a577c76e 100644 --- a/freqtrade/exchange/binance_public_data.py +++ b/freqtrade/exchange/binance_public_data.py @@ -40,7 +40,7 @@ async def fetch_ohlcv( :param until_ms: `None` indicates the timestamp of the latest available data :param stop_on_404: Stop to download the following data when a 404 returned :return: the date range is between [since_ms, until_ms), - return None if no data available in the time range + return and empty DataFrame if no data available in the time range """ if candle_type == CandleType.SPOT: asset_type = "spot" @@ -159,6 +159,9 @@ async def get_daily_ohlcv( """ Get daily OHLCV from https://data.binance.vision See https://github.com/binance/binance-public-data + + :return: None indicates a 404 when trying to download the daily archive file + This function won't raise any exception, but catch and return it """ url = zip_url(asset_type, symbol, timeframe, date)