diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index d552dc65f..52ada40fa 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -135,7 +135,6 @@ class FreqtradeBot(object): """ Refresh tickers asyncronously and return the result. """ - # TODO: maybe add since_ms to use async in the download-script? # TODO: Add tests for this and the async stuff above logger.debug("Refreshing klines for %d pairs", len(pair_list)) datatups = asyncio.get_event_loop().run_until_complete( diff --git a/freqtrade/tests/exchange/test_exchange.py b/freqtrade/tests/exchange/test_exchange.py index 8fa7a6fec..f6b6b105f 100644 --- a/freqtrade/tests/exchange/test_exchange.py +++ b/freqtrade/tests/exchange/test_exchange.py @@ -624,11 +624,6 @@ async def test_async_get_candles_history(default_conf, mocker): # await exchange.async_get_candles_history('ETH/BTC', "5m") -def test_refresh_tickers(): - # TODO: Implement test for this - pass - - def make_fetch_ohlcv_mock(data): def fetch_ohlcv_mock(pair, timeframe, since): if since: diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 3bf6ad037..489392438 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -137,6 +137,36 @@ def test_throttle_with_assets(mocker, default_conf) -> None: assert result == -1 +def test_refresh_tickers(mocker, default_conf, caplog) -> None: + tick = [ + [ + 1511686200000, # unix timestamp ms + 1, # open + 2, # high + 3, # low + 4, # close + 5, # volume (in quote currency) + ] + ] + + async def async_get_candles_history(pairlist, timeframe): + return [(pair, tick) for pair in pairlist] + + caplog.set_level(logging.DEBUG) + freqtrade = get_patched_freqtradebot(mocker, default_conf) + freqtrade.exchange.async_get_candles_history = async_get_candles_history + + pairs = ['IOTA/ETH', 'XRP/ETH'] + # empty dicts + assert not freqtrade._klines + freqtrade.refresh_tickers(['IOTA/ETH', 'XRP/ETH']) + + assert log_has(f'Refreshing klines for {len(pairs)} pairs', caplog.record_tuples) + assert freqtrade._klines + for pair in pairs: + assert freqtrade._klines[pair] + + def test_gen_pair_whitelist(mocker, default_conf, tickers) -> None: freqtrade = get_patched_freqtradebot(mocker, default_conf) mocker.patch('freqtrade.exchange.Exchange.get_tickers', tickers)