refactor: strip fast download logic into a method

This commit is contained in:
Meng Xiangzhuo
2024-11-13 10:16:06 +08:00
parent cf0f232635
commit acc53065e5
2 changed files with 47 additions and 13 deletions

View File

@@ -2224,6 +2224,7 @@ class Exchange:
candle_type: CandleType,
is_new_pair: bool = False,
until_ms: Optional[int] = None,
only_from_ccxt: bool = False,
) -> DataFrame:
"""
Get candle history using asyncio and returns the list of candles.
@@ -2232,8 +2233,10 @@ class Exchange:
:param pair: Pair to download
:param timeframe: Timeframe to get data for
:param since_ms: Timestamp in milliseconds to get history from
:param until_ms: Timestamp in milliseconds to get history up to
:param candle_type: '', mark, index, premiumIndex, or funding_rate
:param is_new_pair: used by binance subclass to allow "fast" new pair downloading
:param until_ms: Timestamp in milliseconds to get history up to
:param only_from_ccxt: Only download data using the API provided by CCXT
:return: Dataframe with candle (OHLCV) data
"""
pair, _, _, data, _ = self.loop.run_until_complete(
@@ -2242,7 +2245,6 @@ class Exchange:
timeframe=timeframe,
since_ms=since_ms,
until_ms=until_ms,
is_new_pair=is_new_pair,
candle_type=candle_type,
)
)
@@ -2255,13 +2257,11 @@ class Exchange:
timeframe: str,
since_ms: int,
candle_type: CandleType,
is_new_pair: bool = False,
raise_: bool = False,
until_ms: Optional[int] = None,
) -> OHLCVResponse:
"""
Download historic ohlcv
:param is_new_pair: used by binance subclass to allow "fast" new pair downloading
:param candle_type: Any of the enum CandleType (must match trading mode!)
"""