Convert _rpc_show_config to static method

This commit is contained in:
Matthias
2020-11-08 11:26:02 +01:00
parent b8f6f09de8
commit 2af1c80fd5
5 changed files with 19 additions and 13 deletions

View File

@@ -329,7 +329,7 @@ class ApiServer(RPC):
"""
Prints the bot's version
"""
return jsonify(self._rpc_show_config(self._config))
return jsonify(RPC._rpc_show_config(self._config, self._freqtrade.state))
@require_login
@rpc_catch_errors

View File

@@ -93,7 +93,8 @@ class RPC:
def send_msg(self, msg: Dict[str, str]) -> None:
""" Sends a message to all registered rpc modules """
def _rpc_show_config(self, config) -> Dict[str, Any]:
@staticmethod
def _rpc_show_config(config, botstate: State) -> Dict[str, Any]:
"""
Return a dict of config options.
Explicitly does NOT return the full config to avoid leakage of sensitive
@@ -104,21 +105,24 @@ class RPC:
'stake_currency': config['stake_currency'],
'stake_amount': config['stake_amount'],
'max_open_trades': config['max_open_trades'],
'minimal_roi': config['minimal_roi'].copy(),
'stoploss': config['stoploss'],
'trailing_stop': config['trailing_stop'],
'minimal_roi': config['minimal_roi'].copy() if 'minimal_roi' in config else {},
'stoploss': config.get('stoploss'),
'trailing_stop': config.get('trailing_stop'),
'trailing_stop_positive': config.get('trailing_stop_positive'),
'trailing_stop_positive_offset': config.get('trailing_stop_positive_offset'),
'trailing_only_offset_is_reached': config.get('trailing_only_offset_is_reached'),
'timeframe': config['timeframe'],
'timeframe_ms': timeframe_to_msecs(config['timeframe']),
'timeframe_min': timeframe_to_minutes(config['timeframe']),
'timeframe': config.get('timeframe'),
'timeframe_ms': timeframe_to_msecs(config['timeframe']
) if 'timeframe' in config else '',
'timeframe_min': timeframe_to_minutes(config['timeframe']
) if 'timeframe' in config else '',
'exchange': config['exchange']['name'],
'strategy': config['strategy'],
'forcebuy_enabled': config.get('forcebuy_enable', False),
'ask_strategy': config.get('ask_strategy', {}),
'bid_strategy': config.get('bid_strategy', {}),
'state': str(self._freqtrade.state) if self._freqtrade else '',
'state': str(botstate),
'runmode': config['runmode'].value
}
return val

View File

@@ -775,7 +775,8 @@ class Telegram(RPC):
:param update: message update
:return: None
"""
val = self._rpc_show_config(self._freqtrade.config)
val = RPC._rpc_show_config(self._freqtrade.config, self._freqtrade.state)
if val['trailing_stop']:
sl_info = (
f"*Initial Stoploss:* `{val['stoploss']}`\n"