Convert _rpc_show_config to static method
This commit is contained in:
parent
b8f6f09de8
commit
2af1c80fd5
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -14,7 +14,7 @@ from freqtrade.__init__ import __version__
|
||||
from freqtrade.loggers import setup_logging, setup_logging_pre
|
||||
from freqtrade.persistence import PairLocks, Trade
|
||||
from freqtrade.rpc.api_server import BASE_URI, ApiServer
|
||||
from freqtrade.state import State
|
||||
from freqtrade.state import RunMode, State
|
||||
from tests.conftest import create_mock_trades, get_patched_freqtradebot, log_has, patch_get_signal
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ _TEST_PASS = "SuperSecurePassword1!"
|
||||
def botclient(default_conf, mocker):
|
||||
setup_logging_pre()
|
||||
setup_logging(default_conf)
|
||||
|
||||
default_conf['runmode'] = RunMode.DRY_RUN
|
||||
default_conf.update({"api_server": {"enabled": True,
|
||||
"listen_ip_address": "127.0.0.1",
|
||||
"listen_port": 8080,
|
||||
|
@ -21,7 +21,7 @@ from freqtrade.loggers import setup_logging
|
||||
from freqtrade.persistence import PairLocks, Trade
|
||||
from freqtrade.rpc import RPCMessageType
|
||||
from freqtrade.rpc.telegram import Telegram, authorized_only
|
||||
from freqtrade.state import State
|
||||
from freqtrade.state import RunMode, State
|
||||
from freqtrade.strategy.interface import SellType
|
||||
from tests.conftest import (create_mock_trades, get_patched_freqtradebot, log_has, patch_exchange,
|
||||
patch_get_signal, patch_whitelist)
|
||||
@ -1309,6 +1309,7 @@ def test_show_config_handle(default_conf, update, mocker) -> None:
|
||||
_init=MagicMock(),
|
||||
_send_msg=msg_mock
|
||||
)
|
||||
default_conf['runmode'] = RunMode.DRY_RUN
|
||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||
telegram = Telegram(freqtradebot)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user