Rename refresh_tickers to refresh_latest_ohlcv
This commit is contained in:
parent
06ec106079
commit
a206777fe5
@ -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]:
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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) ...')
|
||||
|
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -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:
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user