diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index b3da57d20..c41a84450 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2018,8 +2018,8 @@ class Exchange: candle_limit = self.ohlcv_candle_limit( timeframe, candle_type=candle_type, since_ms=since_ms) - if candle_type != CandleType.SPOT: - params.update({'price': candle_type}) + if candle_type and candle_type != CandleType.SPOT: + params.update({'price': candle_type.value}) if candle_type != CandleType.FUNDING_RATE: data = await self._api_async.fetch_ohlcv( pair, timeframe=timeframe, since=since_ms, diff --git a/tests/exchange/test_binance.py b/tests/exchange/test_binance.py index ef5cb1240..75aaa0081 100644 --- a/tests/exchange/test_binance.py +++ b/tests/exchange/test_binance.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, PropertyMock import ccxt import pytest -from freqtrade.enums import MarginMode, TradingMode +from freqtrade.enums import CandleType, MarginMode, TradingMode from freqtrade.exceptions import DependencyException, InvalidOrderException, OperationalException from tests.conftest import get_mock_coro, get_patched_exchange, log_has_re from tests.exchange.test_exchange import ccxt_exceptionhandlers @@ -542,7 +542,7 @@ def test__set_leverage_binance(mocker, default_conf): @pytest.mark.asyncio -@pytest.mark.parametrize('candle_type', ['mark', '']) +@pytest.mark.parametrize('candle_type', [CandleType.MARK, '']) async def test__async_get_historic_ohlcv_binance(default_conf, mocker, caplog, candle_type): ohlcv = [ [ diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 673dc7594..b07892f72 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -2339,7 +2339,8 @@ async def test__async_kucoin_get_candle_history(default_conf, mocker, caplog): for _ in range(3): with pytest.raises(DDosProtection, match=r'429 Too Many Requests'): await exchange._async_get_candle_history( - "ETH/BTC", "5m", (arrow.utcnow().int_timestamp - 2000) * 1000, count=3) + "ETH/BTC", "5m", CandleType.SPOT, + since_ms=(arrow.utcnow().int_timestamp - 2000) * 1000, count=3) assert num_log_has_re(msg, caplog) == 3 caplog.clear() @@ -2355,7 +2356,8 @@ async def test__async_kucoin_get_candle_history(default_conf, mocker, caplog): for _ in range(3): with pytest.raises(DDosProtection, match=r'429 Too Many Requests'): await exchange._async_get_candle_history( - "ETH/BTC", "5m", (arrow.utcnow().int_timestamp - 2000) * 1000, count=3) + "ETH/BTC", "5m", CandleType.SPOT, + (arrow.utcnow().int_timestamp - 2000) * 1000, count=3) # Expect the "returned exception" message 12 times (4 retries * 3 (loop)) assert num_log_has_re(msg, caplog) == 12 assert num_log_has_re(msg2, caplog) == 9