Deprecate --dynamic-whitelist
This commit is contained in:
parent
3360e777a1
commit
1b3ecb8343
@ -115,7 +115,8 @@ class Arguments(object):
|
||||
self.parser.add_argument(
|
||||
'--dynamic-whitelist',
|
||||
help='dynamically generate and update whitelist'
|
||||
' based on 24h BaseVolume (default: %(const)s)',
|
||||
' based on 24h BaseVolume (default: %(const)s)'
|
||||
' DEPRECATED.',
|
||||
dest='dynamic_whitelist',
|
||||
const=constants.DYNAMIC_WHITELIST,
|
||||
type=int,
|
||||
|
@ -110,10 +110,14 @@ class Configuration(object):
|
||||
|
||||
# Add dynamic_whitelist if found
|
||||
if 'dynamic_whitelist' in self.args and self.args.dynamic_whitelist:
|
||||
config.update({'dynamic_whitelist': self.args.dynamic_whitelist})
|
||||
logger.info(
|
||||
'Parameter --dynamic-whitelist detected. '
|
||||
'Using dynamically generated whitelist. '
|
||||
# Update to volumePairList (the previous default)
|
||||
config['whitelist'] = {'method': 'VolumePairList',
|
||||
'config': {'number_assets': self.args.dynamic_whitelist}
|
||||
}
|
||||
logger.warning(
|
||||
'Parameter --dynamic-whitelist has been deprecated, '
|
||||
'and will be completely replaced by the whitelist dict in the future. '
|
||||
'For now: using dynamically generated whitelist based on VolumePairList. '
|
||||
'(not applicable with Backtesting and Hyperopt)'
|
||||
)
|
||||
|
||||
|
@ -124,6 +124,14 @@ CONF_SCHEMA = {
|
||||
'ignore_roi_if_buy_signal_true': {'type': 'boolean'}
|
||||
}
|
||||
},
|
||||
'whitelist': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'method': {'type': 'string'},
|
||||
'config': {'type': 'object'}
|
||||
},
|
||||
'required': ['method']
|
||||
},
|
||||
'telegram': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
|
@ -59,9 +59,8 @@ class FreqtradeBot(object):
|
||||
self.persistence = None
|
||||
self.exchange = Exchange(self.config)
|
||||
self.wallets = Wallets(self.exchange)
|
||||
if self.config.get('dynamic_whitelist', None):
|
||||
if self.config.get('whitelist', {}).get('method') == 'VolumePairList':
|
||||
self.pairlists: StaticPairList = VolumePairList(self, self.config)
|
||||
|
||||
else:
|
||||
self.pairlists: StaticPairList = StaticPairList(self, self.config)
|
||||
|
||||
|
@ -18,9 +18,10 @@ class VolumePairList(StaticPairList):
|
||||
def __init__(self, freqtrade, config: dict) -> None:
|
||||
self._freqtrade = freqtrade
|
||||
self._config = config
|
||||
self._whitelistconf = self._config.get('whitelist', {}).get('config')
|
||||
self._whitelist = self._config['exchange']['pair_whitelist']
|
||||
self._blacklist = self._config['exchange'].get('pair_blacklist', [])
|
||||
self._number_pairs = self._config.get('dynamic_whitelist', None)
|
||||
self._number_pairs = self._whitelistconf.get('number_assets')
|
||||
if not self._freqtrade.exchange.exchange_has('fetchTickers'):
|
||||
raise OperationalException(
|
||||
'Exchange does not support dynamic whitelist.'
|
||||
|
@ -4,7 +4,6 @@ from unittest.mock import MagicMock
|
||||
|
||||
from freqtrade import OperationalException
|
||||
from freqtrade.tests.conftest import get_patched_freqtradebot
|
||||
|
||||
import pytest
|
||||
|
||||
# whitelist, blacklist
|
||||
@ -109,9 +108,11 @@ def test_gen_pair_whitelist(mocker, default_conf, tickers) -> None:
|
||||
|
||||
|
||||
def test_gen_pair_whitelist_not_supported(mocker, default_conf, tickers) -> None:
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
default_conf['whitelist'] = {'method': 'VolumePairList',
|
||||
'config': {'number_assets': 10}
|
||||
}
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_tickers', tickers)
|
||||
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=False))
|
||||
|
||||
with pytest.raises(OperationalException):
|
||||
freqtrade._gen_pair_whitelist(base_currency='BTC')
|
||||
get_patched_freqtradebot(mocker, default_conf)
|
||||
|
@ -119,7 +119,8 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
||||
configuration = Configuration(args)
|
||||
validated_conf = configuration.load_config()
|
||||
|
||||
assert validated_conf.get('dynamic_whitelist') == 10
|
||||
assert validated_conf.get('whitelist', {}).get('method') == 'VolumePairList'
|
||||
assert validated_conf.get('whitelist', {}).get('config').get('number_assets') == 10
|
||||
assert validated_conf.get('strategy') == 'TestStrategy'
|
||||
assert validated_conf.get('strategy_path') == '/some/path'
|
||||
assert validated_conf.get('db_url') == 'sqlite:///someurl'
|
||||
@ -194,8 +195,9 @@ def test_show_info(default_conf, mocker, caplog) -> None:
|
||||
configuration.get_config()
|
||||
|
||||
assert log_has(
|
||||
'Parameter --dynamic-whitelist detected. '
|
||||
'Using dynamically generated whitelist. '
|
||||
'Parameter --dynamic-whitelist has been deprecated, '
|
||||
'and will be completely replaced by the whitelist dict in the future. '
|
||||
'For now: using dynamically generated whitelist based on VolumePairList. '
|
||||
'(not applicable with Backtesting and Hyperopt)',
|
||||
caplog.record_tuples
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user