diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index da9bef0b0..c2c09eb40 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -15,7 +15,7 @@ ARGS_STRATEGY = ["strategy", "strategy_path"] ARGS_MAIN = ARGS_COMMON + ARGS_STRATEGY + ["db_url", "sd_notify"] ARGS_COMMON_OPTIMIZE = ["ticker_interval", "timerange", - "max_open_trades", "stake_amount"] + "max_open_trades", "stake_amount", "fee"] ARGS_BACKTEST = ARGS_COMMON_OPTIMIZE + ["position_stacking", "use_max_market_positions", "strategy_list", "export", "exportfilename"] diff --git a/freqtrade/configuration/cli_options.py b/freqtrade/configuration/cli_options.py index caf34b5e3..9f7f7b82f 100644 --- a/freqtrade/configuration/cli_options.py +++ b/freqtrade/configuration/cli_options.py @@ -144,6 +144,12 @@ AVAILABLE_CLI_OPTIONS = { default=os.path.join('user_data', 'backtest_results', 'backtest-result.json'), ), + "fee": Arg( + '--fee', + help='Specify fee %%. Should be in %%, will be applied twice (on trade entry and exit).', + type=float, + metavar='FLOAT', + ), # Edge "stoploss_range": Arg( '--stoplosses', diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index 764593d0f..ccbc41f34 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -210,6 +210,10 @@ class Configuration: logstring='Parameter --stake_amount detected, ' 'overriding stake_amount to: {} ...') + self._args_to_config(config, argname='fee', + logstring='Parameter --fee detected, ' + 'setting fee to: {} ...') + self._args_to_config(config, argname='timerange', logstring='Parameter --timerange detected: {} ...') @@ -323,7 +327,8 @@ class Configuration: sample: logfun=len (prints the length of the found configuration instead of the content) """ - if argname in self.args and self.args[argname]: + if (argname in self.args and self.args[argname] is not None + and self.args[argname] is not False): config.update({argname: self.args[argname]}) if logfun: diff --git a/freqtrade/edge/__init__.py b/freqtrade/edge/__init__.py index 66a777ce5..2655fbc65 100644 --- a/freqtrade/edge/__init__.py +++ b/freqtrade/edge/__init__.py @@ -77,8 +77,10 @@ class Edge: self._timerange: TimeRange = TimeRange.parse_timerange("%s-" % arrow.now().shift( days=-1 * self._since_number_of_days).format('YYYYMMDD')) - - self.fee = self.exchange.get_fee() + if config.get('fee'): + self.fee = config['fee'] + else: + self.fee = self.exchange.get_fee() def calculate(self) -> bool: pairs = self.config['exchange']['pair_whitelist'] diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 89aff86f6..759d7b72d 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -63,9 +63,12 @@ class Backtesting: self.config['exchange']['uid'] = '' self.config['dry_run'] = True self.strategylist: List[IStrategy] = [] - self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange - self.fee = self.exchange.get_fee() + + if config.get('fee'): + self.fee = config['fee'] + else: + self.fee = self.exchange.get_fee() if self.config.get('runmode') != RunMode.HYPEROPT: self.dataprovider = DataProvider(self.config, self.exchange)