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