Implement pair_blacklist functionality (#257)
* Adding an optional black_list of pairs not to be traded * applying the blacklist also when not using --dynamic-whitelist * fix error retrieving pair in conf * Refactoring the handling of whitelist among the various functions * unit test to verify that black listed pairs are being removed from the pair_whitelist * Fixing newly added unit tests in develop * fixing flake8 code review * fix code review from @garcq
This commit is contained in:
@@ -41,12 +41,10 @@ def test_refresh_whitelist(mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', conf)
|
||||
mocker.patch.multiple('freqtrade.main.exchange',
|
||||
get_wallet_health=get_health)
|
||||
# no argument: use the whitelist provided by config
|
||||
refresh_whitelist()
|
||||
refreshedwhitelist = refresh_whitelist(conf['exchange']['pair_whitelist'])
|
||||
whitelist = ['BTC_ETH', 'BTC_TKN']
|
||||
pairslist = conf['exchange']['pair_whitelist']
|
||||
# Ensure all except those in whitelist are removed
|
||||
assert set(whitelist) == set(pairslist)
|
||||
assert set(whitelist) == set(refreshedwhitelist)
|
||||
|
||||
|
||||
def test_refresh_whitelist_dynamic(mocker):
|
||||
@@ -56,9 +54,8 @@ def test_refresh_whitelist_dynamic(mocker):
|
||||
get_wallet_health=get_health)
|
||||
# argument: use the whitelist dynamically by exchange-volume
|
||||
whitelist = ['BTC_ETH', 'BTC_TKN']
|
||||
refresh_whitelist(whitelist)
|
||||
pairslist = conf['exchange']['pair_whitelist']
|
||||
assert set(whitelist) == set(pairslist)
|
||||
refreshedwhitelist = refresh_whitelist(whitelist)
|
||||
assert set(whitelist) == set(refreshedwhitelist)
|
||||
|
||||
|
||||
def test_refresh_whitelist_dynamic_empty(mocker):
|
||||
|
@@ -180,6 +180,23 @@ def test_create_trade_no_pairs(default_conf, ticker, mocker):
|
||||
create_trade(default_conf['stake_amount'])
|
||||
|
||||
|
||||
def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: True)
|
||||
mocker.patch.multiple('freqtrade.rpc', init=MagicMock(), send_msg=MagicMock())
|
||||
mocker.patch.multiple('freqtrade.main.exchange',
|
||||
validate_pairs=MagicMock(),
|
||||
get_ticker=ticker,
|
||||
buy=MagicMock(return_value='mocked_limit_buy'))
|
||||
|
||||
with pytest.raises(DependencyException, match=r'.*No pair in whitelist.*'):
|
||||
conf = copy.deepcopy(default_conf)
|
||||
conf['exchange']['pair_whitelist'] = ["BTC_ETH"]
|
||||
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
|
||||
mocker.patch.dict('freqtrade.main._CONF', conf)
|
||||
create_trade(default_conf['stake_amount'])
|
||||
|
||||
|
||||
def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: True)
|
||||
|
Reference in New Issue
Block a user