Add plot_config endpoint
This commit is contained in:
parent
d528c44974
commit
677078350f
@ -214,6 +214,8 @@ class ApiServer(RPC):
|
|||||||
view_func=self._trades_delete, methods=['DELETE'])
|
view_func=self._trades_delete, methods=['DELETE'])
|
||||||
self.app.add_url_rule(f'{BASE_URI}/pair_history', 'pair_history',
|
self.app.add_url_rule(f'{BASE_URI}/pair_history', 'pair_history',
|
||||||
view_func=self._analysed_history, methods=['GET'])
|
view_func=self._analysed_history, methods=['GET'])
|
||||||
|
self.app.add_url_rule(f'{BASE_URI}/plot_config', 'plot_config',
|
||||||
|
view_func=self._plot_config, methods=['GET'])
|
||||||
# Combined actions and infos
|
# Combined actions and infos
|
||||||
self.app.add_url_rule(f'{BASE_URI}/blacklist', 'blacklist', view_func=self._blacklist,
|
self.app.add_url_rule(f'{BASE_URI}/blacklist', 'blacklist', view_func=self._blacklist,
|
||||||
methods=['GET', 'POST'])
|
methods=['GET', 'POST'])
|
||||||
@ -521,3 +523,11 @@ class ApiServer(RPC):
|
|||||||
|
|
||||||
results = self._rpc_analysed_history(pair, timeframe, limit)
|
results = self._rpc_analysed_history(pair, timeframe, limit)
|
||||||
return self.rest_dump(results)
|
return self.rest_dump(results)
|
||||||
|
|
||||||
|
@require_login
|
||||||
|
@rpc_catch_errors
|
||||||
|
def _plot_config(self):
|
||||||
|
"""
|
||||||
|
Handler for /plot_config.
|
||||||
|
"""
|
||||||
|
return self.rest_dump(self._rpc_plot_config())
|
||||||
|
@ -654,7 +654,7 @@ class RPC:
|
|||||||
raise RPCException('Edge is not enabled.')
|
raise RPCException('Edge is not enabled.')
|
||||||
return self._freqtrade.edge.accepted_pairs()
|
return self._freqtrade.edge.accepted_pairs()
|
||||||
|
|
||||||
def _rpc_analysed_history(self, pair, timeframe, limit):
|
def _rpc_analysed_history(self, pair, timeframe, limit) -> Dict[str, Any]:
|
||||||
|
|
||||||
_data, last_analyzed = self._freqtrade.dataprovider.get_analyzed_dataframe(pair, timeframe)
|
_data, last_analyzed = self._freqtrade.dataprovider.get_analyzed_dataframe(pair, timeframe)
|
||||||
if limit:
|
if limit:
|
||||||
@ -667,3 +667,7 @@ class RPC:
|
|||||||
'length': len(_data),
|
'length': len(_data),
|
||||||
'last_analyzed': last_analyzed,
|
'last_analyzed': last_analyzed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _rpc_plot_config(self) -> Dict[str, Any]:
|
||||||
|
|
||||||
|
return self._freqtrade.strategy.plot_config
|
||||||
|
@ -835,3 +835,18 @@ def test_api_pair_history(botclient, ohlcv_history):
|
|||||||
[1511686500000, 8.88e-05, 8.942e-05, 8.88e-05,
|
[1511686500000, 8.88e-05, 8.942e-05, 8.88e-05,
|
||||||
8.893e-05, 0.05874751, 8.886500000000001e-05]
|
8.893e-05, 0.05874751, 8.886500000000001e-05]
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_plot_config(botclient):
|
||||||
|
ftbot, client = botclient
|
||||||
|
|
||||||
|
rc = client_get(client, f"{BASE_URI}/plot_config")
|
||||||
|
assert_response(rc)
|
||||||
|
assert rc.json == {}
|
||||||
|
|
||||||
|
ftbot.strategy.plot_config = {'main_plot': {'sma': {}},
|
||||||
|
'subplots': {'RSI': {'rsi': {'color': 'red'}}}}
|
||||||
|
rc = client_get(client, f"{BASE_URI}/plot_config")
|
||||||
|
assert_response(rc)
|
||||||
|
assert rc.json == ftbot.strategy.plot_config
|
||||||
|
assert isinstance(rc.json['main_plot'], dict)
|
||||||
|
Loading…
Reference in New Issue
Block a user