Rename refresh_tickers to refresh_latest_ohlcv

This commit is contained in:
Matthias 2018-12-29 13:13:07 +01:00
parent 06ec106079
commit a206777fe5
8 changed files with 14 additions and 13 deletions

View File

@ -27,7 +27,7 @@ class DataProvider(object):
""" """
Refresh data, called with each cycle 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 @property
def available_pairs(self) -> List[str]: def available_pairs(self) -> List[str]:

View File

@ -530,9 +530,10 @@ class Exchange(object):
logger.info("downloaded %s with length %s.", pair, len(data)) logger.info("downloaded %s with length %s.", pair, len(data))
return 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)) logger.debug("Refreshing klines for %d pairs", len(pair_list))

View File

@ -158,9 +158,9 @@ class FreqtradeBot(object):
self.active_pair_whitelist = self.pairlists.whitelist self.active_pair_whitelist = self.pairlists.whitelist
# Calculating Edge positiong # Calculating Edge positiong
# Should be called before refresh_tickers # Should be called before refresh_latest_ohlcv
# Otherwise it will override cached klines in exchange # 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: if self.edge:
self.edge.calculate() self.edge.calculate()
self.active_pair_whitelist = self.edge.adjust(self.active_pair_whitelist) self.active_pair_whitelist = self.edge.adjust(self.active_pair_whitelist)

View File

@ -368,7 +368,7 @@ class Backtesting(object):
if self.config.get('live'): if self.config.get('live'):
logger.info('Downloading data for all pairs in whitelist ...') 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 data = self.exchange._klines
else: else:
logger.info('Using local backtesting data (using whitelist in given config) ...') logger.info('Using local backtesting data (using whitelist in given config) ...')

View File

@ -778,7 +778,7 @@ def test_get_history(default_conf, mocker, caplog):
assert len(ret) == 2 assert len(ret) == 2
def test_refresh_tickers(mocker, default_conf, caplog) -> None: def test_refresh_latest_ohlcv(mocker, default_conf, caplog) -> None:
tick = [ tick = [
[ [
(arrow.utcnow().timestamp - 1) * 1000, # unix timestamp ms (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'] pairs = ['IOTA/ETH', 'XRP/ETH']
# empty dicts # empty dicts
assert not exchange._klines 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 log_has(f'Refreshing klines for {len(pairs)} pairs', caplog.record_tuples)
assert exchange._klines 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) assert exchange.klines(pair, copy=False) is exchange.klines(pair, copy=False)
# test caching # 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 exchange._api_async.fetch_ohlcv.call_count == 2
assert log_has(f"Using cached klines data for {pairs[0]} ...", caplog.record_tuples) assert log_has(f"Using cached klines data for {pairs[0]} ...", caplog.record_tuples)

View File

@ -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.data.history.load_data', mocked_load_data)
mocker.patch('freqtrade.optimize.get_timeframe', get_timeframe) 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) patch_exchange(mocker)
mocker.patch.multiple( mocker.patch.multiple(
'freqtrade.optimize.backtesting.Backtesting', '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.data.history.load_data', MagicMock(return_value={}))
mocker.patch('freqtrade.optimize.get_timeframe', get_timeframe) 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) patch_exchange(mocker)
mocker.patch.multiple( mocker.patch.multiple(
'freqtrade.optimize.backtesting.Backtesting', 'freqtrade.optimize.backtesting.Backtesting',

View File

@ -43,7 +43,7 @@ def patch_get_signal(freqtrade: FreqtradeBot, value=(True, False)) -> None:
:return: None :return: None
""" """
freqtrade.strategy.get_signal = lambda e, s, t: value 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: def patch_RPCManager(mocker) -> MagicMock:

View File

@ -138,7 +138,7 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
tickers = {} tickers = {}
if args.live: if args.live:
logger.info('Downloading pair.') logger.info('Downloading pair.')
exchange.refresh_tickers([pair], tick_interval) exchange.refresh_latest_ohlcv([pair], tick_interval)
tickers[pair] = exchange.klines(pair) tickers[pair] = exchange.klines(pair)
else: else:
tickers = history.load_data( tickers = history.load_data(