diff --git a/freqtrade/data/dataprovider.py b/freqtrade/data/dataprovider.py index 4f854e647..628ca1dd4 100644 --- a/freqtrade/data/dataprovider.py +++ b/freqtrade/data/dataprovider.py @@ -27,7 +27,7 @@ class DataProvider(object): """ Refresh data, called with each cycle """ - self._exchange.refresh_tickers(pairlist, self._config['ticker_interval']) + self._exchange.refresh_latest_ohlcv(pairlist, self._config['ticker_interval']) @property def available_pairs(self) -> List[str]: diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index 84f20a7fe..03acc2e61 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -530,9 +530,10 @@ class Exchange(object): logger.info("downloaded %s with length %s.", pair, len(data)) return data - def refresh_tickers(self, pair_list: List[str], ticker_interval: str) -> List[Tuple[str, List]]: + def refresh_latest_ohlcv(self, pair_list: List[str], + ticker_interval: str) -> List[Tuple[str, List]]: """ - Refresh ohlcv asyncronously and set `_klines` with the result + Refresh in-memory ohlcv asyncronously and set `_klines` with the result """ logger.debug("Refreshing klines for %d pairs", len(pair_list)) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 071cbaf2e..41cd35da7 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -158,9 +158,9 @@ class FreqtradeBot(object): self.active_pair_whitelist = self.pairlists.whitelist # Calculating Edge positiong - # Should be called before refresh_tickers + # Should be called before refresh_latest_ohlcv # Otherwise it will override cached klines in exchange - # with delta value (klines only from last refresh_pairs) + # with delta value (klines only from last refresh_latest_ohlcv) if self.edge: self.edge.calculate() self.active_pair_whitelist = self.edge.adjust(self.active_pair_whitelist) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 88ad4cc60..192f8cff0 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -368,7 +368,7 @@ class Backtesting(object): if self.config.get('live'): logger.info('Downloading data for all pairs in whitelist ...') - self.exchange.refresh_tickers(pairs, self.ticker_interval) + self.exchange.refresh_latest_ohlcv(pairs, self.ticker_interval) data = self.exchange._klines else: logger.info('Using local backtesting data (using whitelist in given config) ...') diff --git a/freqtrade/tests/exchange/test_exchange.py b/freqtrade/tests/exchange/test_exchange.py index 26808e78a..e0be9a4bb 100644 --- a/freqtrade/tests/exchange/test_exchange.py +++ b/freqtrade/tests/exchange/test_exchange.py @@ -778,7 +778,7 @@ def test_get_history(default_conf, mocker, caplog): assert len(ret) == 2 -def test_refresh_tickers(mocker, default_conf, caplog) -> None: +def test_refresh_latest_ohlcv(mocker, default_conf, caplog) -> None: tick = [ [ (arrow.utcnow().timestamp - 1) * 1000, # unix timestamp ms @@ -805,7 +805,7 @@ def test_refresh_tickers(mocker, default_conf, caplog) -> None: pairs = ['IOTA/ETH', 'XRP/ETH'] # empty dicts assert not exchange._klines - exchange.refresh_tickers(['IOTA/ETH', 'XRP/ETH'], '5m') + exchange.refresh_latest_ohlcv(['IOTA/ETH', 'XRP/ETH'], '5m') assert log_has(f'Refreshing klines for {len(pairs)} pairs', caplog.record_tuples) assert exchange._klines @@ -822,7 +822,7 @@ def test_refresh_tickers(mocker, default_conf, caplog) -> None: assert exchange.klines(pair, copy=False) is exchange.klines(pair, copy=False) # test caching - exchange.refresh_tickers(['IOTA/ETH', 'XRP/ETH'], '5m') + exchange.refresh_latest_ohlcv(['IOTA/ETH', 'XRP/ETH'], '5m') assert exchange._api_async.fetch_ohlcv.call_count == 2 assert log_has(f"Using cached klines data for {pairs[0]} ...", caplog.record_tuples) diff --git a/freqtrade/tests/optimize/test_backtesting.py b/freqtrade/tests/optimize/test_backtesting.py index beef1b16e..b0e5da0f8 100644 --- a/freqtrade/tests/optimize/test_backtesting.py +++ b/freqtrade/tests/optimize/test_backtesting.py @@ -448,7 +448,7 @@ def test_backtesting_start(default_conf, mocker, caplog) -> None: mocker.patch('freqtrade.data.history.load_data', mocked_load_data) mocker.patch('freqtrade.optimize.get_timeframe', get_timeframe) - mocker.patch('freqtrade.exchange.Exchange.refresh_tickers', MagicMock()) + mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', MagicMock()) patch_exchange(mocker) mocker.patch.multiple( 'freqtrade.optimize.backtesting.Backtesting', @@ -483,7 +483,7 @@ def test_backtesting_start_no_data(default_conf, mocker, caplog) -> None: mocker.patch('freqtrade.data.history.load_data', MagicMock(return_value={})) mocker.patch('freqtrade.optimize.get_timeframe', get_timeframe) - mocker.patch('freqtrade.exchange.Exchange.refresh_tickers', MagicMock()) + mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', MagicMock()) patch_exchange(mocker) mocker.patch.multiple( 'freqtrade.optimize.backtesting.Backtesting', diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 1149a69e9..ca6190ae4 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -43,7 +43,7 @@ def patch_get_signal(freqtrade: FreqtradeBot, value=(True, False)) -> None: :return: None """ freqtrade.strategy.get_signal = lambda e, s, t: value - freqtrade.exchange.refresh_tickers = lambda p, i: None + freqtrade.exchange.refresh_latest_ohlcv = lambda p, i: None def patch_RPCManager(mocker) -> MagicMock: diff --git a/scripts/plot_dataframe.py b/scripts/plot_dataframe.py index ae9cd7f1d..8f3e8327a 100755 --- a/scripts/plot_dataframe.py +++ b/scripts/plot_dataframe.py @@ -138,7 +138,7 @@ def plot_analyzed_dataframe(args: Namespace) -> None: tickers = {} if args.live: logger.info('Downloading pair.') - exchange.refresh_tickers([pair], tick_interval) + exchange.refresh_latest_ohlcv([pair], tick_interval) tickers[pair] = exchange.klines(pair) else: tickers = history.load_data(