Add rest endpoint for /locks

This commit is contained in:
Matthias
2020-10-17 17:58:07 +02:00
parent 7a9768ffa6
commit cd2866eaec
4 changed files with 49 additions and 4 deletions

View File

@@ -751,8 +751,11 @@ class PairLock(_DECL_BASE):
def to_json(self) -> Dict[str, Any]:
return {
'pair': self.pair,
'lock_time': self.lock_time,
'lock_end_time': self.lock_end_time,
'lock_time': self.lock_time.strftime("%Y-%m-%d %H:%M:%S"),
'lock_timestamp': int(self.lock_time.replace(tzinfo=timezone.utc).timestamp() * 1000),
'lock_end_time': self.lock_end_time.strftime("%Y-%m-%d %H:%M:%S"),
'lock_end_timestamp': int(self.lock_end_time.replace(tzinfo=timezone.utc
).timestamp() * 1000),
'reason': self.reason,
'active': self.active,
}

View File

@@ -192,6 +192,7 @@ class ApiServer(RPC):
self.app.add_url_rule(f'{BASE_URI}/balance', 'balance',
view_func=self._balance, methods=['GET'])
self.app.add_url_rule(f'{BASE_URI}/count', 'count', view_func=self._count, methods=['GET'])
self.app.add_url_rule(f'{BASE_URI}/locks', 'locks', view_func=self._locks, methods=['GET'])
self.app.add_url_rule(f'{BASE_URI}/daily', 'daily', view_func=self._daily, methods=['GET'])
self.app.add_url_rule(f'{BASE_URI}/edge', 'edge', view_func=self._edge, methods=['GET'])
self.app.add_url_rule(f'{BASE_URI}/logs', 'log', view_func=self._get_logs, methods=['GET'])
@@ -350,6 +351,15 @@ class ApiServer(RPC):
msg = self._rpc_count()
return jsonify(msg)
@require_login
@rpc_catch_errors
def _locks(self):
"""
Handler for /locks.
Returns the number of trades running
"""
return jsonify(self._rpc_locks())
@require_login
@rpc_catch_errors
def _daily(self):