Add analyzed_history endpoint

This commit is contained in:
Matthias 2020-06-12 19:32:44 +02:00
parent d2111c088b
commit 9dfbc1a7ff
2 changed files with 24 additions and 0 deletions

View File

@ -212,6 +212,8 @@ class ApiServer(RPC):
view_func=self._trades, methods=['GET'])
self.app.add_url_rule(f'{BASE_URI}/trades/<int:tradeid>', 'trades_delete',
view_func=self._trades_delete, methods=['DELETE'])
self.app.add_url_rule(f'{BASE_URI}/pair_history', 'pair_history',
view_func=self._analysed_history, methods=['GET'])
# Combined actions and infos
self.app.add_url_rule(f'{BASE_URI}/blacklist', 'blacklist', view_func=self._blacklist,
methods=['GET', 'POST'])
@ -500,3 +502,15 @@ class ApiServer(RPC):
tradeid = request.json.get("tradeid")
results = self._rpc_forcesell(tradeid)
return self.rest_dump(results)
@require_login
@rpc_catch_errors
def _analysed_history(self):
"""
Handler for /pair_history.
"""
pair = request.args.get("pair")
timeframe = request.args.get("timeframe")
results = self._rpc_analysed_history(pair, timeframe)
return self.rest_dump(results)

View File

@ -653,3 +653,13 @@ class RPC:
if not self._freqtrade.edge:
raise RPCException('Edge is not enabled.')
return self._freqtrade.edge.accepted_pairs()
def _rpc_analysed_history(self, pair, timeframe):
data, last_analyzed = self._freqtrade.dataprovider.get_analyzed_dataframe(pair, timeframe)
return {
'columns': data.columns,
'data': data.values.tolist(),
'length': len(data),
'last_analyzed': last_analyzed,
}