Add rpc_whitelist call

This commit is contained in:
Matthias 2018-11-10 20:07:09 +01:00
parent 2e4e5c86da
commit 02527eeea4
2 changed files with 32 additions and 0 deletions

View File

@ -443,3 +443,10 @@ class RPC(object):
raise RPCException('trader is not running') raise RPCException('trader is not running')
return Trade.query.filter(Trade.is_open.is_(True)).all() return Trade.query.filter(Trade.is_open.is_(True)).all()
def _rpc_whitelist(self) -> Dict:
""" Returns the currently active whitelist"""
res = {'method': self._freqtrade.config.get('dynamic_whitelist', 0) or 'static',
'whitelist': self._freqtrade.active_pair_whitelist
}
return res

View File

@ -645,3 +645,28 @@ def test_rpcforcebuy_disabled(mocker, default_conf) -> None:
pair = 'ETH/BTC' pair = 'ETH/BTC'
with pytest.raises(RPCException, match=r'Forcebuy not enabled.'): with pytest.raises(RPCException, match=r'Forcebuy not enabled.'):
rpc._rpc_forcebuy(pair, None) rpc._rpc_forcebuy(pair, None)
def test_rpc_whitelist(mocker, default_conf) -> None:
patch_coinmarketcap(mocker)
patch_exchange(mocker)
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
freqtradebot = FreqtradeBot(default_conf)
rpc = RPC(freqtradebot)
ret = rpc._rpc_whitelist()
assert ret['method'] == 'static'
assert ret['whitelist'] == default_conf['exchange']['pair_whitelist']
def test_rpc_whitelist_dynamic(mocker, default_conf) -> None:
patch_coinmarketcap(mocker)
patch_exchange(mocker)
default_conf['dynamic_whitelist'] = 4
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
freqtradebot = FreqtradeBot(default_conf)
rpc = RPC(freqtradebot)
ret = rpc._rpc_whitelist()
assert ret['method'] == 4
assert ret['whitelist'] == default_conf['exchange']['pair_whitelist']