Provide available pairs

This commit is contained in:
Matthias 2018-12-26 14:23:21 +01:00
parent f034235af4
commit d3a37db79a
2 changed files with 23 additions and 5 deletions

View File

@ -29,6 +29,14 @@ class DataProvider(object):
"""
self._exchange.refresh_tickers(pairlist, self._config['ticker_interval'])
@property
def available_pairs(self) -> List[str]:
"""
Return a list of pairs for which data is currently cached.
Should be whitelist + open trades.
"""
return list(self._exchange._klines.keys())
def ohlcv(self, pair: str, copy: bool = True) -> List[str]:
"""
get ohlcv data for the given pair as DataFrame

View File

@ -10,12 +10,12 @@ def test_ohlcv(mocker, default_conf, ticker_history):
exchange = get_patched_exchange(mocker, default_conf)
exchange._klines['XRP/BTC'] = ticker_history
exchange._klines['UNITEST/BTC'] = ticker_history
exchange._klines['UNITTEST/BTC'] = ticker_history
dp = DataProvider(default_conf, exchange)
assert ticker_history.equals(dp.ohlcv('UNITEST/BTC'))
assert isinstance(dp.ohlcv('UNITEST/BTC'), DataFrame)
assert dp.ohlcv('UNITEST/BTC') is not ticker_history
assert dp.ohlcv('UNITEST/BTC', copy=False) is ticker_history
assert ticker_history.equals(dp.ohlcv('UNITTEST/BTC'))
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
assert dp.ohlcv('UNITTEST/BTC') is not ticker_history
assert dp.ohlcv('UNITTEST/BTC', copy=False) is ticker_history
assert dp.ohlcv('NONESENSE/AAA') is None
@ -32,3 +32,13 @@ def test_historic_ohlcv(mocker, default_conf, ticker_history):
assert historymock.call_args_list[0][1]['datadir'] is None
assert historymock.call_args_list[0][1]['refresh_pairs'] is False
assert historymock.call_args_list[0][1]['ticker_interval'] == '5m'
def test_available_pairs(mocker, default_conf, ticker_history):
exchange = get_patched_exchange(mocker, default_conf)
exchange._klines['XRP/BTC'] = ticker_history
exchange._klines['UNITTEST/BTC'] = ticker_history
dp = DataProvider(default_conf, exchange)
assert len(dp.available_pairs) == 2
assert dp.available_pairs == ['XRP/BTC', 'UNITTEST/BTC']