From 02527eeea404f5b461b657238a34b3e47712e3ae Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 10 Nov 2018 20:07:09 +0100 Subject: [PATCH] Add rpc_whitelist call --- freqtrade/rpc/rpc.py | 7 +++++++ freqtrade/tests/rpc/test_rpc.py | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index c3cbce2e7..cf283c6b1 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -443,3 +443,10 @@ class RPC(object): raise RPCException('trader is not running') 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 diff --git a/freqtrade/tests/rpc/test_rpc.py b/freqtrade/tests/rpc/test_rpc.py index 19692db50..ff72ef634 100644 --- a/freqtrade/tests/rpc/test_rpc.py +++ b/freqtrade/tests/rpc/test_rpc.py @@ -645,3 +645,28 @@ def test_rpcforcebuy_disabled(mocker, default_conf) -> None: pair = 'ETH/BTC' with pytest.raises(RPCException, match=r'Forcebuy not enabled.'): 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']