Add show_config endpoint
This commit is contained in:
parent
841c379797
commit
2c976bdd24
@ -169,6 +169,8 @@ class ApiServer(RPC):
|
|||||||
view_func=self._status, methods=['GET'])
|
view_func=self._status, methods=['GET'])
|
||||||
self.app.add_url_rule(f'{BASE_URI}/version', 'version',
|
self.app.add_url_rule(f'{BASE_URI}/version', 'version',
|
||||||
view_func=self._version, methods=['GET'])
|
view_func=self._version, methods=['GET'])
|
||||||
|
self.app.add_url_rule(f'{BASE_URI}/show_config', 'show_config',
|
||||||
|
view_func=self._show_config, methods=['GET'])
|
||||||
self.app.add_url_rule(f'{BASE_URI}/ping', 'ping',
|
self.app.add_url_rule(f'{BASE_URI}/ping', 'ping',
|
||||||
view_func=self._ping, methods=['GET'])
|
view_func=self._ping, methods=['GET'])
|
||||||
|
|
||||||
@ -241,6 +243,14 @@ class ApiServer(RPC):
|
|||||||
"""
|
"""
|
||||||
return self.rest_dump({"version": __version__})
|
return self.rest_dump({"version": __version__})
|
||||||
|
|
||||||
|
@require_login
|
||||||
|
@rpc_catch_errors
|
||||||
|
def _show_config(self):
|
||||||
|
"""
|
||||||
|
Prints the bot's version
|
||||||
|
"""
|
||||||
|
return self.rest_dump(self._rpc_show_config())
|
||||||
|
|
||||||
@require_login
|
@require_login
|
||||||
@rpc_catch_errors
|
@rpc_catch_errors
|
||||||
def _reload_conf(self):
|
def _reload_conf(self):
|
||||||
|
@ -80,6 +80,26 @@ class RPC:
|
|||||||
def send_msg(self, msg: Dict[str, str]) -> None:
|
def send_msg(self, msg: Dict[str, str]) -> None:
|
||||||
""" Sends a message to all registered rpc modules """
|
""" Sends a message to all registered rpc modules """
|
||||||
|
|
||||||
|
def _rpc_show_config(self) -> Dict:
|
||||||
|
"""
|
||||||
|
Return a dict of config options.
|
||||||
|
Explicitly does NOT return the full config to avoid leakage of sensitive
|
||||||
|
information via rpc.
|
||||||
|
"""
|
||||||
|
config = self._freqtrade.config
|
||||||
|
val = {
|
||||||
|
'dry_run': config.get('dry_run', False),
|
||||||
|
'stake_currency': config['stake_currency'],
|
||||||
|
'stake_amount': config['stake_amount'],
|
||||||
|
'minimal_roi': config['minimal_roi'].copy(),
|
||||||
|
'stoploss': config['stoploss'],
|
||||||
|
'trailing_stop': config['trailing_stop'],
|
||||||
|
'ticker_interval': config['ticker_interval'],
|
||||||
|
'exchange': config['exchange']['name'],
|
||||||
|
'strategy': config['strategy'],
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
|
||||||
def _rpc_trade_status(self) -> List[Dict[str, Any]]:
|
def _rpc_trade_status(self) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is
|
Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is
|
||||||
|
@ -147,6 +147,13 @@ class FtRestClient():
|
|||||||
"""
|
"""
|
||||||
return self._get("version")
|
return self._get("version")
|
||||||
|
|
||||||
|
def show_config(self):
|
||||||
|
"""
|
||||||
|
Returns part of the configuration, relevant for trading operations.
|
||||||
|
:return: json object containing the version
|
||||||
|
"""
|
||||||
|
return self._get("show_config")
|
||||||
|
|
||||||
def whitelist(self):
|
def whitelist(self):
|
||||||
"""
|
"""
|
||||||
Show the current whitelist
|
Show the current whitelist
|
||||||
|
@ -284,6 +284,18 @@ def test_api_count(botclient, mocker, ticker, fee, markets):
|
|||||||
assert rc.json["max"] == 1.0
|
assert rc.json["max"] == 1.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_show_config(botclient, mocker):
|
||||||
|
ftbot, client = botclient
|
||||||
|
patch_get_signal(ftbot, (True, False))
|
||||||
|
|
||||||
|
rc = client_get(client, f"{BASE_URI}/show_config")
|
||||||
|
assert_response(rc)
|
||||||
|
assert 'dry_run' in rc.json
|
||||||
|
assert rc.json['exchange'] == 'bittrex'
|
||||||
|
assert rc.json['ticker_interval'] == '5m'
|
||||||
|
assert not rc.json['trailing_stop']
|
||||||
|
|
||||||
|
|
||||||
def test_api_daily(botclient, mocker, ticker, fee, markets):
|
def test_api_daily(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
ftbot, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(ftbot, (True, False))
|
||||||
|
Loading…
Reference in New Issue
Block a user