Skip to content

Commit

Permalink
add --fee to change fees to other values
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Oct 5, 2019
1 parent 2c0d2c1 commit 0664a8c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion freqtrade/configuration/arguments.py
Expand Up @@ -15,7 +15,7 @@
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"]
Expand Down
6 changes: 6 additions & 0 deletions freqtrade/configuration/cli_options.py
Expand Up @@ -144,6 +144,12 @@ def __init__(self, *args, **kwargs):
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',
Expand Down
7 changes: 6 additions & 1 deletion freqtrade/configuration/configuration.py
Expand Up @@ -210,6 +210,10 @@ def _process_optimize_options(self, config: Dict[str, Any]) -> None:
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: {} ...')

Expand Down Expand Up @@ -323,7 +327,8 @@ def _args_to_config(self, config: Dict[str, Any], argname: str,
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:
Expand Down
6 changes: 4 additions & 2 deletions freqtrade/edge/__init__.py
Expand Up @@ -77,8 +77,10 @@ def __init__(self, config: Dict[str, Any], exchange, strategy) -> None:

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']
Expand Down
7 changes: 5 additions & 2 deletions freqtrade/optimize/backtesting.py
Expand Up @@ -63,9 +63,12 @@ def __init__(self, config: Dict[str, Any]) -> None:
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)
Expand Down

0 comments on commit 0664a8c

Please sign in to comment.