From b1964851c9d9bc7153abf6b93a774bf2a4873fd1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 26 Apr 2019 10:03:54 +0200 Subject: [PATCH] Add performance handlers --- freqtrade/rpc/api_server.py | 18 ++++++++++++++++-- scripts/rest_client.py | 9 ++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/freqtrade/rpc/api_server.py b/freqtrade/rpc/api_server.py index 009ae7d68..f63c68bf1 100644 --- a/freqtrade/rpc/api_server.py +++ b/freqtrade/rpc/api_server.py @@ -113,6 +113,8 @@ class ApiServer(RPC): app.add_url_rule('/count', 'count', view_func=self._count, methods=['GET']) app.add_url_rule('/daily', 'daily', view_func=self._daily, methods=['GET']) app.add_url_rule('/profit', 'profit', view_func=self._profit, methods=['GET']) + app.add_url_rule('/performance', 'performance', view_func=self._performance, + methods=['GET']) app.add_url_rule('/status', 'status', view_func=self._status, methods=['GET']) app.add_url_rule('/version', 'version', view_func=self._version, methods=['GET']) @@ -122,10 +124,8 @@ class ApiServer(RPC): app.add_url_rule('/whitelist', 'whitelist', view_func=self._whitelist, methods=['GET']) # TODO: Implement the following - # performance # forcebuy # forcesell - # blacklist params # edge # help (?) @@ -266,6 +266,20 @@ class ApiServer(RPC): return self.rest_dump(stats) + @safe_rpc + def _performance(self): + """ + Handler for /performance. + + Returns a cumulative performance statistics + :return: stats + """ + logger.info("LocalRPC - performance Command Called") + + stats = self._rpc_performance() + + return self.rest_dump(stats) + @safe_rpc def _status(self): """ diff --git a/scripts/rest_client.py b/scripts/rest_client.py index 1958c1a07..7dbed9bc5 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -45,7 +45,7 @@ class FtRestClient(): # Split url schema, netloc, path, par, query, fragment = urlparse(basepath) # URLEncode query string - query = urlencode(params) if params else None + query = urlencode(params) if params else "" # recombine url url = urlunparse((schema, netloc, path, par, query, fragment)) @@ -92,6 +92,13 @@ class FtRestClient(): """ return self._get("profit") + def performance(self): + """ + Returns the performance of the different coins + :returns: json object + """ + return self._get("performance") + def status(self): """ Get the status of open trades