Rename --realistic-simulation to --enable-position-stacking
This commit is contained in:
parent
78205da4f0
commit
e17618407b
@ -127,8 +127,8 @@ optional arguments:
|
|||||||
-i TICKER_INTERVAL, --ticker-interval TICKER_INTERVAL
|
-i TICKER_INTERVAL, --ticker-interval TICKER_INTERVAL
|
||||||
specify ticker interval (1m, 5m, 30m, 1h, 1d)
|
specify ticker interval (1m, 5m, 30m, 1h, 1d)
|
||||||
--realistic-simulation
|
--realistic-simulation
|
||||||
uses max_open_trades from config to simulate real
|
Disables buying the same pair multiple times to
|
||||||
world limitations
|
simulate real world limitations
|
||||||
--timerange TIMERANGE
|
--timerange TIMERANGE
|
||||||
specify what timerange of data to use.
|
specify what timerange of data to use.
|
||||||
-l, --live using live data
|
-l, --live using live data
|
||||||
@ -173,8 +173,8 @@ optional arguments:
|
|||||||
-i TICKER_INTERVAL, --ticker-interval TICKER_INTERVAL
|
-i TICKER_INTERVAL, --ticker-interval TICKER_INTERVAL
|
||||||
specify ticker interval (1m, 5m, 30m, 1h, 1d)
|
specify ticker interval (1m, 5m, 30m, 1h, 1d)
|
||||||
--realistic-simulation
|
--realistic-simulation
|
||||||
uses max_open_trades from config to simulate real
|
Disables buying the same pair multiple times to
|
||||||
world limitations
|
simulate real world limitations
|
||||||
--timerange TIMERANGE specify what timerange of data to use.
|
--timerange TIMERANGE specify what timerange of data to use.
|
||||||
-e INT, --epochs INT specify number of epochs (default: 100)
|
-e INT, --epochs INT specify number of epochs (default: 100)
|
||||||
-s {all,buy,roi,stoploss} [{all,buy,roi,stoploss} ...], --spaces {all,buy,roi,stoploss} [{all,buy,roi,stoploss} ...]
|
-s {all,buy,roi,stoploss} [{all,buy,roi,stoploss} ...], --spaces {all,buy,roi,stoploss} [{all,buy,roi,stoploss} ...]
|
||||||
|
@ -178,10 +178,11 @@ class Arguments(object):
|
|||||||
type=str,
|
type=str,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--realistic-simulation',
|
'--enable-position-stacking',
|
||||||
help='uses max_open_trades from config to simulate real world limitations',
|
help='Allow buying the same pair twice (position stacking)',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='realistic_simulation',
|
dest='position_stacking',
|
||||||
|
default=False
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--timerange',
|
'--timerange',
|
||||||
|
@ -142,10 +142,11 @@ class Configuration(object):
|
|||||||
config.update({'live': True})
|
config.update({'live': True})
|
||||||
logger.info('Parameter -l/--live detected ...')
|
logger.info('Parameter -l/--live detected ...')
|
||||||
|
|
||||||
# If --realistic-simulation is used we add it to the configuration
|
# If --enable-position-stacking is used we add it to the configuration
|
||||||
if 'realistic_simulation' in self.args and self.args.realistic_simulation:
|
if 'position_stacking' in self.args and self.args.position_stacking:
|
||||||
config.update({'realistic_simulation': True})
|
config.update({'position_stacking': True})
|
||||||
logger.info('Parameter --realistic-simulation detected ...')
|
logger.info('Parameter --enable-position-stacking detected ...')
|
||||||
|
|
||||||
logger.info('Using max_open_trades: %s ...', config.get('max_open_trades'))
|
logger.info('Using max_open_trades: %s ...', config.get('max_open_trades'))
|
||||||
|
|
||||||
# If --timerange is used we add it to the configuration
|
# If --timerange is used we add it to the configuration
|
||||||
@ -182,7 +183,7 @@ class Configuration(object):
|
|||||||
Extract information for sys.argv and load Hyperopt configuration
|
Extract information for sys.argv and load Hyperopt configuration
|
||||||
:return: configuration as dictionary
|
:return: configuration as dictionary
|
||||||
"""
|
"""
|
||||||
# If --realistic-simulation is used we add it to the configuration
|
# If --epochs is used we add it to the configuration
|
||||||
if 'epochs' in self.args and self.args.epochs:
|
if 'epochs' in self.args and self.args.epochs:
|
||||||
config.update({'epochs': self.args.epochs})
|
config.update({'epochs': self.args.epochs})
|
||||||
logger.info('Parameter --epochs detected ...')
|
logger.info('Parameter --epochs detected ...')
|
||||||
|
@ -198,13 +198,13 @@ class Backtesting(object):
|
|||||||
stake_amount: btc amount to use for each trade
|
stake_amount: btc amount to use for each trade
|
||||||
processed: a processed dictionary with format {pair, data}
|
processed: a processed dictionary with format {pair, data}
|
||||||
max_open_trades: maximum number of concurrent trades (default: 0, disabled)
|
max_open_trades: maximum number of concurrent trades (default: 0, disabled)
|
||||||
realistic: do we try to simulate realistic trades? (default: True)
|
position_stacking: do we allow position stacking? (default: False)
|
||||||
:return: DataFrame
|
:return: DataFrame
|
||||||
"""
|
"""
|
||||||
headers = ['date', 'buy', 'open', 'close', 'sell']
|
headers = ['date', 'buy', 'open', 'close', 'sell']
|
||||||
processed = args['processed']
|
processed = args['processed']
|
||||||
max_open_trades = args.get('max_open_trades', 0)
|
max_open_trades = args.get('max_open_trades', 0)
|
||||||
realistic = args.get('realistic', False)
|
position_stacking = args.get('position_stacking', False)
|
||||||
trades = []
|
trades = []
|
||||||
trade_count_lock: Dict = {}
|
trade_count_lock: Dict = {}
|
||||||
for pair, pair_data in processed.items():
|
for pair, pair_data in processed.items():
|
||||||
@ -228,7 +228,7 @@ class Backtesting(object):
|
|||||||
if row.buy == 0 or row.sell == 1:
|
if row.buy == 0 or row.sell == 1:
|
||||||
continue # skip rows where no buy signal or that would immediately sell off
|
continue # skip rows where no buy signal or that would immediately sell off
|
||||||
|
|
||||||
if realistic:
|
if not position_stacking:
|
||||||
if lock_pair_until is not None and row.date <= lock_pair_until:
|
if lock_pair_until is not None and row.date <= lock_pair_until:
|
||||||
continue
|
continue
|
||||||
if max_open_trades > 0:
|
if max_open_trades > 0:
|
||||||
@ -283,10 +283,11 @@ class Backtesting(object):
|
|||||||
logger.critical("No data found. Terminating.")
|
logger.critical("No data found. Terminating.")
|
||||||
return
|
return
|
||||||
# Ignore max_open_trades in backtesting, except realistic flag was passed
|
# Ignore max_open_trades in backtesting, except realistic flag was passed
|
||||||
if self.config.get('realistic_simulation', False):
|
# TODO: this is not position stacking!!
|
||||||
|
if self.config.get('position_stacking', False):
|
||||||
max_open_trades = self.config['max_open_trades']
|
max_open_trades = self.config['max_open_trades']
|
||||||
else:
|
else:
|
||||||
logger.info('Ignoring max_open_trades (realistic_simulation not set) ...')
|
logger.info('Ignoring max_open_trades (position_stacking not set) ...')
|
||||||
max_open_trades = 0
|
max_open_trades = 0
|
||||||
|
|
||||||
preprocessed = self.tickerdata_to_dataframe(data)
|
preprocessed = self.tickerdata_to_dataframe(data)
|
||||||
@ -306,7 +307,7 @@ class Backtesting(object):
|
|||||||
'stake_amount': self.config.get('stake_amount'),
|
'stake_amount': self.config.get('stake_amount'),
|
||||||
'processed': preprocessed,
|
'processed': preprocessed,
|
||||||
'max_open_trades': max_open_trades,
|
'max_open_trades': max_open_trades,
|
||||||
'realistic': self.config.get('realistic_simulation', False),
|
'position_stacking': self.config.get('position_stacking', False),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class Hyperopt(Backtesting):
|
|||||||
{
|
{
|
||||||
'stake_amount': self.config['stake_amount'],
|
'stake_amount': self.config['stake_amount'],
|
||||||
'processed': processed,
|
'processed': processed,
|
||||||
'realistic': self.config.get('realistic_simulation', False),
|
'position_stacking': self.config.get('position_stacking', False),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
result_explanation = self.format_results(results)
|
result_explanation = self.format_results(results)
|
||||||
|
@ -96,7 +96,7 @@ def simple_backtest(config, contour, num_results, mocker) -> None:
|
|||||||
'stake_amount': config['stake_amount'],
|
'stake_amount': config['stake_amount'],
|
||||||
'processed': processed,
|
'processed': processed,
|
||||||
'max_open_trades': 1,
|
'max_open_trades': 1,
|
||||||
'realistic': True
|
'position_stacking': False
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# results :: <class 'pandas.core.frame.DataFrame'>
|
# results :: <class 'pandas.core.frame.DataFrame'>
|
||||||
@ -127,7 +127,7 @@ def _make_backtest_conf(mocker, conf=None, pair='UNITTEST/BTC', record=None):
|
|||||||
'stake_amount': conf['stake_amount'],
|
'stake_amount': conf['stake_amount'],
|
||||||
'processed': backtesting.tickerdata_to_dataframe(data),
|
'processed': backtesting.tickerdata_to_dataframe(data),
|
||||||
'max_open_trades': 10,
|
'max_open_trades': 10,
|
||||||
'realistic': True,
|
'position_stacking': False,
|
||||||
'record': record
|
'record': record
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +193,8 @@ def test_setup_configuration_without_arguments(mocker, default_conf, caplog) ->
|
|||||||
assert 'live' not in config
|
assert 'live' not in config
|
||||||
assert not log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
assert not log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'realistic_simulation' not in config
|
assert 'position_stacking' not in config
|
||||||
assert not log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
assert not log_has('Parameter --enable-position-stacking detected ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'refresh_pairs' not in config
|
assert 'refresh_pairs' not in config
|
||||||
assert not log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
assert not log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||||
@ -218,7 +218,7 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
|||||||
'backtesting',
|
'backtesting',
|
||||||
'--ticker-interval', '1m',
|
'--ticker-interval', '1m',
|
||||||
'--live',
|
'--live',
|
||||||
'--realistic-simulation',
|
'--enable-position-stacking',
|
||||||
'--refresh-pairs-cached',
|
'--refresh-pairs-cached',
|
||||||
'--timerange', ':100',
|
'--timerange', ':100',
|
||||||
'--export', '/bar/foo',
|
'--export', '/bar/foo',
|
||||||
@ -246,8 +246,8 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
|||||||
assert 'live' in config
|
assert 'live' in config
|
||||||
assert log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
assert log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'realistic_simulation' in config
|
assert 'position_stacking' in config
|
||||||
assert log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
assert log_has('Parameter --enable-position-stacking detected ...', caplog.record_tuples)
|
||||||
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'refresh_pairs' in config
|
assert 'refresh_pairs' in config
|
||||||
@ -495,7 +495,7 @@ def test_backtest(default_conf, fee, mocker) -> None:
|
|||||||
'stake_amount': default_conf['stake_amount'],
|
'stake_amount': default_conf['stake_amount'],
|
||||||
'processed': data_processed,
|
'processed': data_processed,
|
||||||
'max_open_trades': 10,
|
'max_open_trades': 10,
|
||||||
'realistic': True
|
'position_stacking': False
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert not results.empty
|
assert not results.empty
|
||||||
@ -543,7 +543,7 @@ def test_backtest_1min_ticker_interval(default_conf, fee, mocker) -> None:
|
|||||||
'stake_amount': default_conf['stake_amount'],
|
'stake_amount': default_conf['stake_amount'],
|
||||||
'processed': backtesting.tickerdata_to_dataframe(data),
|
'processed': backtesting.tickerdata_to_dataframe(data),
|
||||||
'max_open_trades': 1,
|
'max_open_trades': 1,
|
||||||
'realistic': True
|
'position_stacking': False
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert not results.empty
|
assert not results.empty
|
||||||
@ -718,7 +718,7 @@ def test_backtest_start_live(default_conf, mocker, caplog):
|
|||||||
'--ticker-interval', '1m',
|
'--ticker-interval', '1m',
|
||||||
'--live',
|
'--live',
|
||||||
'--timerange', '-100',
|
'--timerange', '-100',
|
||||||
'--realistic-simulation'
|
'--enable-position-stacking'
|
||||||
]
|
]
|
||||||
args = get_args(args)
|
args = get_args(args)
|
||||||
start(args)
|
start(args)
|
||||||
@ -734,7 +734,7 @@ def test_backtest_start_live(default_conf, mocker, caplog):
|
|||||||
'Using stake_amount: 0.001 ...',
|
'Using stake_amount: 0.001 ...',
|
||||||
'Downloading data for all pairs in whitelist ...',
|
'Downloading data for all pairs in whitelist ...',
|
||||||
'Measuring data from 2017-11-14T19:31:00+00:00 up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
'Measuring data from 2017-11-14T19:31:00+00:00 up to 2017-11-14T22:58:00+00:00 (0 days)..',
|
||||||
'Parameter --realistic-simulation detected ...'
|
'Parameter --enable-position-stacking detected ...'
|
||||||
]
|
]
|
||||||
|
|
||||||
for line in exists:
|
for line in exists:
|
||||||
|
@ -275,8 +275,8 @@ def test_setup_configuration_without_arguments(mocker, default_conf, caplog) ->
|
|||||||
assert 'live' not in config
|
assert 'live' not in config
|
||||||
assert not log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
assert not log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'realistic_simulation' not in config
|
assert 'position_stacking' not in config
|
||||||
assert not log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
assert not log_has('Parameter --enable-position-stacking detected ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'refresh_pairs' not in config
|
assert 'refresh_pairs' not in config
|
||||||
assert not log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
assert not log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||||
@ -300,7 +300,7 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
|||||||
'backtesting',
|
'backtesting',
|
||||||
'--ticker-interval', '1m',
|
'--ticker-interval', '1m',
|
||||||
'--live',
|
'--live',
|
||||||
'--realistic-simulation',
|
'--enable-position-stacking',
|
||||||
'--refresh-pairs-cached',
|
'--refresh-pairs-cached',
|
||||||
'--timerange', ':100',
|
'--timerange', ':100',
|
||||||
'--export', '/bar/foo'
|
'--export', '/bar/foo'
|
||||||
@ -330,8 +330,8 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
|||||||
assert 'live' in config
|
assert 'live' in config
|
||||||
assert log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
assert log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'realistic_simulation'in config
|
assert 'position_stacking'in config
|
||||||
assert log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
assert log_has('Parameter --enable-position-stacking detected ...', caplog.record_tuples)
|
||||||
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
||||||
|
|
||||||
assert 'refresh_pairs'in config
|
assert 'refresh_pairs'in config
|
||||||
|
Loading…
Reference in New Issue
Block a user