Update missing candle_type params

This commit is contained in:
Matthias 2021-12-03 16:44:05 +01:00
parent e75f31ee86
commit 5b779fd68b
3 changed files with 15 additions and 12 deletions

View File

@ -206,7 +206,7 @@ class Binance(Exchange):
:param candle_type: Any of the enum CandleType (must match trading mode!) :param candle_type: Any of the enum CandleType (must match trading mode!)
""" """
if is_new_pair: if is_new_pair:
x = await self._async_get_candle_history(pair, timeframe, 0, candle_type) x = await self._async_get_candle_history(pair, timeframe, candle_type, 0)
if x and x[3] and x[3][0] and x[3][0][0] > since_ms: if x and x[3] and x[3][0] and x[3][0][0] > since_ms:
# Set starting date to first available candle. # Set starting date to first available candle.
since_ms = x[3][0][0] since_ms = x[3][0][0]

View File

@ -1364,7 +1364,7 @@ class Exchange:
arrow.utcnow().shift(seconds=one_call // 1000).humanize(only_distance=True) arrow.utcnow().shift(seconds=one_call // 1000).humanize(only_distance=True)
) )
input_coroutines = [self._async_get_candle_history( input_coroutines = [self._async_get_candle_history(
pair, timeframe, since, candle_type=candle_type) for since in pair, timeframe, candle_type, since) for since in
range(since_ms, arrow.utcnow().int_timestamp * 1000, one_call)] range(since_ms, arrow.utcnow().int_timestamp * 1000, one_call)]
data: List = [] data: List = []
@ -1475,8 +1475,8 @@ class Exchange:
self, self,
pair: str, pair: str,
timeframe: str, timeframe: str,
candle_type: CandleType,
since_ms: Optional[int] = None, since_ms: Optional[int] = None,
candle_type: str = '',
) -> Tuple[str, str, str, List]: ) -> Tuple[str, str, str, List]:
""" """
Asynchronously get candle history data using fetch_ohlcv Asynchronously get candle history data using fetch_ohlcv

View File

@ -1792,12 +1792,12 @@ async def test__async_get_candle_history(default_conf, mocker, caplog, exchange_
exchange._api_async.fetch_ohlcv = get_mock_coro(ohlcv) exchange._api_async.fetch_ohlcv = get_mock_coro(ohlcv)
pair = 'ETH/BTC' pair = 'ETH/BTC'
res = await exchange._async_get_candle_history(pair, "5m") res = await exchange._async_get_candle_history(pair, "5m", CandleType.SPOT)
assert type(res) is tuple assert type(res) is tuple
assert len(res) == 4 assert len(res) == 4
assert res[0] == pair assert res[0] == pair
assert res[1] == "5m" assert res[1] == "5m"
assert res[2] == '' assert res[2] == CandleType.SPOT
assert res[3] == ohlcv assert res[3] == ohlcv
assert exchange._api_async.fetch_ohlcv.call_count == 1 assert exchange._api_async.fetch_ohlcv.call_count == 1
assert not log_has(f"Using cached candle (OHLCV) data for {pair} ...", caplog) assert not log_has(f"Using cached candle (OHLCV) data for {pair} ...", caplog)
@ -1805,21 +1805,22 @@ async def test__async_get_candle_history(default_conf, mocker, caplog, exchange_
# exchange = Exchange(default_conf) # exchange = Exchange(default_conf)
await async_ccxt_exception(mocker, default_conf, MagicMock(), await async_ccxt_exception(mocker, default_conf, MagicMock(),
"_async_get_candle_history", "fetch_ohlcv", "_async_get_candle_history", "fetch_ohlcv",
pair='ABCD/BTC', timeframe=default_conf['timeframe']) pair='ABCD/BTC', timeframe=default_conf['timeframe'],
candle_type=CandleType.SPOT)
api_mock = MagicMock() api_mock = MagicMock()
with pytest.raises(OperationalException, with pytest.raises(OperationalException,
match=r'Could not fetch historical candle \(OHLCV\) data.*'): match=r'Could not fetch historical candle \(OHLCV\) data.*'):
api_mock.fetch_ohlcv = MagicMock(side_effect=ccxt.BaseError("Unknown error")) api_mock.fetch_ohlcv = MagicMock(side_effect=ccxt.BaseError("Unknown error"))
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name) exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
await exchange._async_get_candle_history(pair, "5m", await exchange._async_get_candle_history(pair, "5m", CandleType.SPOT,
(arrow.utcnow().int_timestamp - 2000) * 1000) (arrow.utcnow().int_timestamp - 2000) * 1000)
with pytest.raises(OperationalException, match=r'Exchange.* does not support fetching ' with pytest.raises(OperationalException, match=r'Exchange.* does not support fetching '
r'historical candle \(OHLCV\) data\..*'): r'historical candle \(OHLCV\) data\..*'):
api_mock.fetch_ohlcv = MagicMock(side_effect=ccxt.NotSupported("Not supported")) api_mock.fetch_ohlcv = MagicMock(side_effect=ccxt.NotSupported("Not supported"))
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name) exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
await exchange._async_get_candle_history(pair, "5m", await exchange._async_get_candle_history(pair, "5m", CandleType.SPOT,
(arrow.utcnow().int_timestamp - 2000) * 1000) (arrow.utcnow().int_timestamp - 2000) * 1000)
@ -1835,12 +1836,12 @@ async def test__async_get_candle_history_empty(default_conf, mocker, caplog):
exchange = Exchange(default_conf) exchange = Exchange(default_conf)
pair = 'ETH/BTC' pair = 'ETH/BTC'
res = await exchange._async_get_candle_history(pair, "5m") res = await exchange._async_get_candle_history(pair, "5m", CandleType.SPOT)
assert type(res) is tuple assert type(res) is tuple
assert len(res) == 4 assert len(res) == 4
assert res[0] == pair assert res[0] == pair
assert res[1] == "5m" assert res[1] == "5m"
assert res[2] == '' assert res[2] == zCandleType.SPOT
assert res[3] == ohlcv assert res[3] == ohlcv
assert exchange._api_async.fetch_ohlcv.call_count == 1 assert exchange._api_async.fetch_ohlcv.call_count == 1
@ -2140,7 +2141,8 @@ async def test___async_get_candle_history_sort(default_conf, mocker, exchange_na
exchange._api_async.fetch_ohlcv = get_mock_coro(ohlcv) exchange._api_async.fetch_ohlcv = get_mock_coro(ohlcv)
sort_mock = mocker.patch('freqtrade.exchange.exchange.sorted', MagicMock(side_effect=sort_data)) sort_mock = mocker.patch('freqtrade.exchange.exchange.sorted', MagicMock(side_effect=sort_data))
# Test the OHLCV data sort # Test the OHLCV data sort
res = await exchange._async_get_candle_history('ETH/BTC', default_conf['timeframe']) res = await exchange._async_get_candle_history(
'ETH/BTC', default_conf['timeframe'], CandleType.SPOT)
assert res[0] == 'ETH/BTC' assert res[0] == 'ETH/BTC'
res_ohlcv = res[3] res_ohlcv = res[3]
@ -2177,7 +2179,8 @@ async def test___async_get_candle_history_sort(default_conf, mocker, exchange_na
# Reset sort mock # Reset sort mock
sort_mock = mocker.patch('freqtrade.exchange.sorted', MagicMock(side_effect=sort_data)) sort_mock = mocker.patch('freqtrade.exchange.sorted', MagicMock(side_effect=sort_data))
# Test the OHLCV data sort # Test the OHLCV data sort
res = await exchange._async_get_candle_history('ETH/BTC', default_conf['timeframe']) res = await exchange._async_get_candle_history(
'ETH/BTC', default_conf['timeframe'], CandleType.SPOT)
assert res[0] == 'ETH/BTC' assert res[0] == 'ETH/BTC'
assert res[1] == default_conf['timeframe'] assert res[1] == default_conf['timeframe']
res_ohlcv = res[3] res_ohlcv = res[3]