chore: remove direct exchange connection

This commit is contained in:
Matthias
2024-11-29 06:46:55 +01:00
parent d1710826e6
commit fa1e0af19f
2 changed files with 15 additions and 15 deletions

View File

@@ -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()

View File

@@ -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