Implement /delete for api-server
This commit is contained in:
parent
c0083c4244
commit
215972c68f
@ -200,6 +200,8 @@ class ApiServer(RPC):
|
|||||||
view_func=self._ping, methods=['GET'])
|
view_func=self._ping, methods=['GET'])
|
||||||
self.app.add_url_rule(f'{BASE_URI}/trades', 'trades',
|
self.app.add_url_rule(f'{BASE_URI}/trades', 'trades',
|
||||||
view_func=self._trades, methods=['GET'])
|
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'])
|
||||||
# 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'])
|
||||||
@ -424,6 +426,15 @@ class ApiServer(RPC):
|
|||||||
results = self._rpc_trade_history(limit)
|
results = self._rpc_trade_history(limit)
|
||||||
return self.rest_dump(results)
|
return self.rest_dump(results)
|
||||||
|
|
||||||
|
@require_login
|
||||||
|
@rpc_catch_errors
|
||||||
|
def _trades_delete(self, tradeid):
|
||||||
|
"""
|
||||||
|
Handler for DELETE /trades/<tradeid> endpoint.
|
||||||
|
"""
|
||||||
|
result = self._rpc_delete(tradeid)
|
||||||
|
return self.rest_dump(result)
|
||||||
|
|
||||||
@require_login
|
@require_login
|
||||||
@rpc_catch_errors
|
@rpc_catch_errors
|
||||||
def _whitelist(self):
|
def _whitelist(self):
|
||||||
|
@ -537,7 +537,7 @@ class RPC:
|
|||||||
return trade
|
return trade
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _rpc_delete(self, trade_id: str) -> Dict[str, str]:
|
def _rpc_delete(self, trade_id: str) -> Dict[str, str]:
|
||||||
"""
|
"""
|
||||||
Handler for delete <id>.
|
Handler for delete <id>.
|
||||||
@ -558,7 +558,7 @@ class RPC:
|
|||||||
_exec_delete(trade)
|
_exec_delete(trade)
|
||||||
Trade.session.flush()
|
Trade.session.flush()
|
||||||
self._freqtrade.wallets.update()
|
self._freqtrade.wallets.update()
|
||||||
return {'result': f'Deleted trade {trade_id}.'}
|
return {'result_msg': f'Deleted trade {trade_id}.'}
|
||||||
|
|
||||||
def _rpc_performance(self) -> List[Dict[str, Any]]:
|
def _rpc_performance(self) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
|
@ -547,7 +547,7 @@ class Telegram(RPC):
|
|||||||
trade_id = context.args[0] if len(context.args) > 0 else None
|
trade_id = context.args[0] if len(context.args) > 0 else None
|
||||||
try:
|
try:
|
||||||
msg = self._rpc_delete(trade_id)
|
msg = self._rpc_delete(trade_id)
|
||||||
self._send_msg('Delete Result: `{result}`'.format(**msg))
|
self._send_msg('Delete Result: `{result_msg}`'.format(**msg))
|
||||||
|
|
||||||
except RPCException as e:
|
except RPCException as e:
|
||||||
self._send_msg(str(e))
|
self._send_msg(str(e))
|
||||||
|
Loading…
Reference in New Issue
Block a user