refactor: rename fetch_ohlcv to download_archive_ohlcv

This commit is contained in:
xzmeng
2024-11-14 07:29:37 +08:00
parent 8baa0f7310
commit 660863392b
4 changed files with 19 additions and 13 deletions

View File

@@ -763,7 +763,7 @@ def patch_ohlcv(mocker, start, archive_end, api_end, timeframe):
until = dt_from_ts(until_ms) if until_ms else api_end + timedelta(seconds=1)
return api_storage.loc[(api_storage["date"] >= since) & (api_storage["date"] < until)]
async def fetch_ohlcv(
async def download_archive_ohlcv(
candle_type,
pair,
timeframe,
@@ -787,7 +787,7 @@ def patch_ohlcv(mocker, start, archive_end, api_end, timeframe):
"freqtrade.exchange.Exchange.get_historic_ohlcv", side_effect=get_historic_ohlcv
)
archive_mock = mocker.patch(
"freqtrade.exchange.binance_public_data.fetch_ohlcv", side_effect=fetch_ohlcv
"freqtrade.exchange.binance.download_archive_ohlcv", side_effect=download_archive_ohlcv
)
return candle_mock, api_mock, archive_mock

View File

@@ -14,7 +14,7 @@ from freqtrade.enums import CandleType
from freqtrade.exchange.binance_public_data import (
BadHttpStatus,
Http404,
fetch_ohlcv,
download_archive_ohlcv,
get_daily_ohlcv,
zip_name,
)
@@ -196,7 +196,9 @@ def make_response_from_url(start_date, end_date):
),
],
)
async def test_fetch_ohlcv(mocker, candle_type, since, until, first_date, last_date, stop_on_404):
async def test_download_archive_ohlcv(
mocker, candle_type, since, until, first_date, last_date, stop_on_404
):
history_start = dt_utc(2020, 1, 1).date()
history_end = dt_utc(2020, 1, 3).date()
timeframe = "1h"
@@ -214,7 +216,9 @@ async def test_fetch_ohlcv(mocker, candle_type, since, until, first_date, last_d
)
markets = {"BTC/USDT": {"id": "BTCUSDT"}, "BTC/USDT:USDT": {"id": "BTCUSDT"}}
df = await fetch_ohlcv(candle_type, pair, timeframe, since_ms, until_ms, markets, stop_on_404)
df = await download_archive_ohlcv(
candle_type, pair, timeframe, since_ms, until_ms, markets, stop_on_404
)
if df.empty:
assert first_date is None and last_date is None
@@ -224,7 +228,7 @@ async def test_fetch_ohlcv(mocker, candle_type, since, until, first_date, last_d
assert df["date"].iloc[-1] == last_date
async def test_fetch_ohlcv_exc(mocker):
async def test_download_archive_ohlcv_exc(mocker):
timeframe = "1h"
pair = "BTC/USDT"
@@ -240,7 +244,7 @@ async def test_fetch_ohlcv_exc(mocker):
{"BTC/USDT": {"id": "BTCUSDT"}},
)
df = await fetch_ohlcv(CandleType.SPOT, pair, timeframe, since_ms, until_ms)
df = await download_archive_ohlcv(CandleType.SPOT, pair, timeframe, since_ms, until_ms)
assert df.empty