feat: more binance fast download timeframes

This commit is contained in:
Meng Xiangzhuo
2024-11-02 04:02:43 +08:00
parent c3bbedbc56
commit 76187d31cf
2 changed files with 7 additions and 2 deletions

View File

@@ -134,7 +134,9 @@ class Binance(Exchange):
) )
return DataFrame(columns=DEFAULT_DATAFRAME_COLUMNS) 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( df = self.loop.run_until_complete(
binance_public_data.fetch_ohlcv( binance_public_data.fetch_ohlcv(
candle_type=candle_type, candle_type=candle_type,

View File

@@ -40,7 +40,7 @@ async def fetch_ohlcv(
:param until_ms: `None` indicates the timestamp of the latest available data :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 :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: 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: if candle_type == CandleType.SPOT:
asset_type = "spot" asset_type = "spot"
@@ -159,6 +159,9 @@ async def get_daily_ohlcv(
""" """
Get daily OHLCV from https://data.binance.vision Get daily OHLCV from https://data.binance.vision
See https://github.com/binance/binance-public-data 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) url = zip_url(asset_type, symbol, timeframe, date)