add --disable-max-market-positions
This commit is contained in:
parent
b29eed32ca
commit
c82276ecbe
@ -184,6 +184,16 @@ class Arguments(object):
|
||||
dest='position_stacking',
|
||||
default=False
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--disable-max-market-positions',
|
||||
help='Disable applying `max_open_trades` during backtest '
|
||||
'(same as setting `max_open_trades` to a very high number)',
|
||||
action='store_false',
|
||||
dest='use_max_market_positions',
|
||||
default=True
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--timerange',
|
||||
help='specify what timerange of data to use.',
|
||||
|
@ -147,6 +147,12 @@ class Configuration(object):
|
||||
config.update({'position_stacking': True})
|
||||
logger.info('Parameter --enable-position-stacking detected ...')
|
||||
|
||||
# If --disable-max-market-positions is used we add it to the configuration
|
||||
if 'use_max_market_positions' in self.args and not self.args.use_max_market_positions:
|
||||
config.update({'use_max_market_positions': False})
|
||||
logger.info('Parameter --disable-max-market-positions detected ...')
|
||||
logger.info('max_open_trades set to unlimited ...')
|
||||
else:
|
||||
logger.info('Using max_open_trades: %s ...', config.get('max_open_trades'))
|
||||
|
||||
# If --timerange is used we add it to the configuration
|
||||
|
@ -282,12 +282,11 @@ class Backtesting(object):
|
||||
if not data:
|
||||
logger.critical("No data found. Terminating.")
|
||||
return
|
||||
# Ignore max_open_trades in backtesting, except realistic flag was passed
|
||||
# TODO: this is not position stacking!!
|
||||
if self.config.get('position_stacking', False):
|
||||
# Use max_open_trades in backtesting, except --disable-max-market-positions is set
|
||||
if self.config.get('use_max_market_positions', True):
|
||||
max_open_trades = self.config['max_open_trades']
|
||||
else:
|
||||
logger.info('Ignoring max_open_trades (position_stacking not set) ...')
|
||||
logger.info('Ignoring max_open_trades (--disable-max-market-positions was used) ...')
|
||||
max_open_trades = 0
|
||||
|
||||
preprocessed = self.tickerdata_to_dataframe(data)
|
||||
|
@ -219,6 +219,7 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
||||
'--ticker-interval', '1m',
|
||||
'--live',
|
||||
'--enable-position-stacking',
|
||||
'--disable-max-market-positions',
|
||||
'--refresh-pairs-cached',
|
||||
'--timerange', ':100',
|
||||
'--export', '/bar/foo',
|
||||
@ -248,7 +249,10 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
||||
|
||||
assert 'position_stacking' in config
|
||||
assert log_has('Parameter --enable-position-stacking detected ...', caplog.record_tuples)
|
||||
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
||||
|
||||
assert 'use_max_market_positions' in config
|
||||
assert log_has('Parameter --disable-max-market-positions detected ...', caplog.record_tuples)
|
||||
assert log_has('max_open_trades set to unlimited ...', caplog.record_tuples)
|
||||
|
||||
assert 'refresh_pairs' in config
|
||||
assert log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||
@ -718,7 +722,8 @@ def test_backtest_start_live(default_conf, mocker, caplog):
|
||||
'--ticker-interval', '1m',
|
||||
'--live',
|
||||
'--timerange', '-100',
|
||||
'--enable-position-stacking'
|
||||
'--enable-position-stacking',
|
||||
'--disable-max-market-positions'
|
||||
]
|
||||
args = get_args(args)
|
||||
start(args)
|
||||
@ -727,7 +732,7 @@ def test_backtest_start_live(default_conf, mocker, caplog):
|
||||
'Parameter -i/--ticker-interval detected ...',
|
||||
'Using ticker_interval: 1m ...',
|
||||
'Parameter -l/--live detected ...',
|
||||
'Using max_open_trades: 1 ...',
|
||||
'Ignoring max_open_trades (--disable-max-market-positions was used) ...',
|
||||
'Parameter --timerange detected: -100 ...',
|
||||
'Using data folder: freqtrade/tests/testdata ...',
|
||||
'Using stake_currency: BTC ...',
|
||||
|
@ -301,6 +301,7 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
||||
'--ticker-interval', '1m',
|
||||
'--live',
|
||||
'--enable-position-stacking',
|
||||
'--disable-max-market-positions',
|
||||
'--refresh-pairs-cached',
|
||||
'--timerange', ':100',
|
||||
'--export', '/bar/foo'
|
||||
@ -332,7 +333,10 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
||||
|
||||
assert 'position_stacking'in config
|
||||
assert log_has('Parameter --enable-position-stacking detected ...', caplog.record_tuples)
|
||||
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
||||
|
||||
assert 'use_max_market_positions' in config
|
||||
assert log_has('Parameter --disable-max-market-positions detected ...', caplog.record_tuples)
|
||||
assert log_has('max_open_trades set to unlimited ...', caplog.record_tuples)
|
||||
|
||||
assert 'refresh_pairs'in config
|
||||
assert log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||
|
Loading…
Reference in New Issue
Block a user