mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
chore: remove direct exchange connection
This commit is contained in:
@@ -39,9 +39,10 @@ async def download_archive_ohlcv(
|
||||
candle_type: CandleType,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
*,
|
||||
since_ms: int,
|
||||
until_ms: int | None,
|
||||
markets: dict[str, Any] | None = None,
|
||||
markets: dict[str, Any],
|
||||
stop_on_404: bool = True,
|
||||
) -> DataFrame:
|
||||
"""
|
||||
@@ -70,12 +71,7 @@ async def download_archive_ohlcv(
|
||||
else:
|
||||
raise ValueError(f"Unsupported CandleType: {candle_type}")
|
||||
|
||||
if markets:
|
||||
symbol = markets[pair]["id"]
|
||||
else:
|
||||
binance = ccxt.binance()
|
||||
binance.load_markets()
|
||||
symbol = binance.markets[pair]["id"]
|
||||
symbol = markets[pair]["id"]
|
||||
|
||||
start = dt_from_ts(since_ms)
|
||||
end = dt_from_ts(until_ms) if until_ms else dt_now()
|
||||
|
||||
@@ -243,7 +243,13 @@ async def test_download_archive_ohlcv(
|
||||
markets = {"BTC/USDT": {"id": "BTCUSDT"}, "BTC/USDT:USDT": {"id": "BTCUSDT"}}
|
||||
|
||||
df = await download_archive_ohlcv(
|
||||
candle_type, pair, timeframe, since_ms, until_ms, markets, stop_on_404
|
||||
candle_type,
|
||||
pair,
|
||||
timeframe,
|
||||
since_ms=since_ms,
|
||||
until_ms=until_ms,
|
||||
markets=markets,
|
||||
stop_on_404=stop_on_404,
|
||||
)
|
||||
|
||||
if df.empty:
|
||||
@@ -254,23 +260,21 @@ async def test_download_archive_ohlcv(
|
||||
assert df["date"].iloc[-1] == last_date
|
||||
|
||||
|
||||
async def test_download_archive_ohlcv_exc(mocker):
|
||||
async def test_download_archive_ohlcv_exception(mocker):
|
||||
timeframe = "1h"
|
||||
pair = "BTC/USDT"
|
||||
|
||||
since_ms = dt_ts(dt_utc(2020, 1, 1))
|
||||
until_ms = dt_ts(dt_utc(2020, 1, 2))
|
||||
|
||||
markets = {"BTC/USDT": {"id": "BTCUSDT"}, "BTC/USDT:USDT": {"id": "BTCUSDT"}}
|
||||
mocker.patch(
|
||||
"freqtrade.exchange.binance_public_data.aiohttp.ClientSession.get", side_effect=RuntimeError
|
||||
)
|
||||
mocker.patch("freqtrade.exchange.binance_public_data.ccxt.binance")
|
||||
mocker.patch(
|
||||
"freqtrade.exchange.binance_public_data.ccxt.binance.markets",
|
||||
{"BTC/USDT": {"id": "BTCUSDT"}},
|
||||
)
|
||||
|
||||
df = await download_archive_ohlcv(CandleType.SPOT, pair, timeframe, since_ms, until_ms)
|
||||
df = await download_archive_ohlcv(
|
||||
CandleType.SPOT, pair, timeframe, since_ms=since_ms, until_ms=until_ms, markets=markets
|
||||
)
|
||||
|
||||
assert df.empty
|
||||
|
||||
|
||||
Reference in New Issue
Block a user