Add additional pairs to refresh call
This commit is contained in:
parent
fc92491a47
commit
e66808bb02
@ -23,10 +23,15 @@ class DataProvider(object):
|
||||
self._config = config
|
||||
self._exchange = exchange
|
||||
|
||||
def refresh(self, pairlist: List[Tuple[str, str]]) -> None:
|
||||
def refresh(self,
|
||||
pairlist: List[Tuple[str, str]],
|
||||
helping_pairs: List[Tuple[str, str]] = None) -> None:
|
||||
"""
|
||||
Refresh data, called with each cycle
|
||||
"""
|
||||
if helping_pairs:
|
||||
self._exchange.refresh_latest_ohlcv(pairlist + helping_pairs)
|
||||
else:
|
||||
self._exchange.refresh_latest_ohlcv(pairlist)
|
||||
|
||||
@property
|
||||
|
@ -174,7 +174,8 @@ class FreqtradeBot(object):
|
||||
pair_whitelist_tuple = [(pair, self.config['ticker_interval'])
|
||||
for pair in self.active_pair_whitelist]
|
||||
# Refreshing candles
|
||||
self.dataprovider.refresh(pair_whitelist_tuple)
|
||||
self.dataprovider.refresh(pair_whitelist_tuple,
|
||||
self.strategy.additional_pairs())
|
||||
|
||||
# First process current opened trades
|
||||
for trade in trades:
|
||||
|
@ -61,3 +61,33 @@ def test_available_pairs(mocker, default_conf, ticker_history):
|
||||
|
||||
assert len(dp.available_pairs) == 2
|
||||
assert dp.available_pairs == [('XRP/BTC', tick_interval), ('UNITTEST/BTC', tick_interval)]
|
||||
|
||||
|
||||
def test_refresh(mocker, default_conf, ticker_history):
|
||||
refresh_mock = MagicMock()
|
||||
mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', refresh_mock)
|
||||
|
||||
exchange = get_patched_exchange(mocker, default_conf, id='binance')
|
||||
tick_interval = default_conf['ticker_interval']
|
||||
pairs = [('XRP/BTC', tick_interval),
|
||||
('UNITTEST/BTC', tick_interval),
|
||||
]
|
||||
|
||||
pairs_non_trad = [('ETH/USDT', tick_interval),
|
||||
('BTC/TUSD', "1h"),
|
||||
]
|
||||
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
dp.refresh(pairs)
|
||||
|
||||
assert refresh_mock.call_count == 1
|
||||
assert len(refresh_mock.call_args[0]) == 1
|
||||
assert len(refresh_mock.call_args[0][0]) == len(pairs)
|
||||
assert refresh_mock.call_args[0][0] == pairs
|
||||
|
||||
refresh_mock.reset_mock()
|
||||
dp.refresh(pairs, pairs_non_trad)
|
||||
assert refresh_mock.call_count == 1
|
||||
assert len(refresh_mock.call_args[0]) == 1
|
||||
assert len(refresh_mock.call_args[0][0]) == len(pairs) + len(pairs_non_trad)
|
||||
assert refresh_mock.call_args[0][0] == pairs + pairs_non_trad
|
||||
|
Loading…
Reference in New Issue
Block a user