In backtesting, ensure we don't buy the same pair again before selling (#139)

* in backtesting, ensure we don't buy before we sell

* no overlapping trades only if max_open_trades > 0

* --limit-max-trades now --realistic-simulation
This commit is contained in:
Mathieu Favréaux
2017-11-24 20:09:44 +00:00
committed by Michael Egger
parent cfbfe90aa0
commit 371ee1e457
3 changed files with 15 additions and 8 deletions

View File

@@ -147,10 +147,10 @@ def build_subcommands(parser: argparse.ArgumentParser) -> None:
metavar='INT',
)
backtest.add_argument(
'--limit-max-trades',
'--realistic-simulation',
help='uses max_open_trades from config to simulate real world limitations',
action='store_true',
dest='limit_max_trades',
dest='realistic_simulation',
)
@@ -167,7 +167,7 @@ def start_backtesting(args) -> None:
'BACKTEST_LIVE': 'true' if args.live else '',
'BACKTEST_CONFIG': args.config,
'BACKTEST_TICKER_INTERVAL': str(args.ticker_interval),
'BACKTEST_LIMIT_MAX_TRADES': 'true' if args.limit_max_trades else '',
'BACKTEST_REALISTIC_SIMULATION': 'true' if args.realistic_simulation else '',
})
path = os.path.join(os.path.dirname(__file__), 'tests', 'test_backtesting.py')
pytest.main(['-s', path])