Improve handling of backtesting params

This commit is contained in:
Matthias
2021-02-26 19:48:06 +01:00
parent 86f9409fd2
commit 98f3142b30
6 changed files with 39 additions and 16 deletions

View File

@@ -111,7 +111,7 @@ AVAILABLE_CLI_OPTIONS = {
action='store_true',
),
"dry_run_wallet": Arg(
'--dry-run-wallet',
'--dry-run-wallet', '--starting-balance',
help='Starting balance, used for backtesting / hyperopt and dry-runs.',
type=float,
),

View File

@@ -4,6 +4,7 @@ from typing import Any, Dict
from freqtrade import constants
from freqtrade.configuration import setup_utils_configuration
from freqtrade.exceptions import OperationalException
from freqtrade.misc import round_coin_value
from freqtrade.state import RunMode
@@ -22,9 +23,13 @@ def setup_optimize_configuration(args: Dict[str, Any], method: RunMode) -> Dict[
RunMode.BACKTEST: 'backtesting',
RunMode.HYPEROPT: 'hyperoptimization',
}
if (method in no_unlimited_runmodes.keys() and
config['stake_amount'] != constants.UNLIMITED_STAKE_AMOUNT and
config['max_open_trades'] != float('inf')):
if method in no_unlimited_runmodes.keys():
if (config['stake_amount'] != constants.UNLIMITED_STAKE_AMOUNT
and config['stake_amount'] > config['dry_run_wallet']):
wallet = round_coin_value(config['dry_run_wallet'], config['stake_currency'])
stake = round_coin_value(config['stake_amount'], config['stake_currency'])
raise OperationalException(f"Starting balance ({wallet}) "
f"is smaller than stake_amount {stake}.")
pass
# config['dry_run_wallet'] = config['stake_amount'] * \
# config['max_open_trades'] * (2 - config['tradable_balance_ratio'])