From 6bb1ad288e6d74b749e11ec7d8490ebe1ab1b466 Mon Sep 17 00:00:00 2001 From: creslinux Date: Wed, 13 Jun 2018 22:26:21 +0000 Subject: [PATCH] Implemented local restful flask service and provided cmdline client Added only the "Daily" call so far, submitting for early review/feedback Called as example "./rest_client.py daily 3" This depends on listed as requirements. Flask==1.0.2 flask-jsonpify==1.5.0 (will do later) flask-restful==0.3.6 TODO: make loading optional, cleanly unload on close unit tests, take feedback, tidy output, add other Telegram functions, onwards local rest server is enabled/disabled from within config.json. E.g "localrest": { "enabled": true }, The server is enabled from within existing rpc manager and makes use of the existing superclass (RPC) Through making use of the existing hard work done in rpc.py It *should be easy to add the other Telegram calls into local_rpc_server.py The server is wrapped in a thread to be non-blocking The server and client accept serialised calls or not, used in daily to return json The client can be used from command line or in a python client script As example, from cmdline for last 3 days Daily DannyMBP:rpc creslin$ ./rest_client.py daily 3 [ [ "2018-06-13", "0.00000000 USDT", "0.000 USD", "0 trade" ], [ "2018-06-12", "0.00000000 USDT", "0.000 USD", "0 trade" ], [ "2018-06-11", "0.00000000 USDT", "0.000 USD", "0 trade" ] ] --- freqtrade/rpc/local_rest_server.py | 2 +- freqtrade/rpc/rest_client.py | 2 +- freqtrade/rpc/rpc_manager.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/rpc/local_rest_server.py b/freqtrade/rpc/local_rest_server.py index 940cc5942..0c9fad16b 100644 --- a/freqtrade/rpc/local_rest_server.py +++ b/freqtrade/rpc/local_rest_server.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) class Daily(Resource): # called by http://127.0.0.1:/daily?timescale=7 - # where 7 is the number of days to report back with. + # where 7 is the number of days to report back with def __init__(self, freqtrade) -> None: """ diff --git a/freqtrade/rpc/rest_client.py b/freqtrade/rpc/rest_client.py index 5b39b7a0b..928e1798c 100755 --- a/freqtrade/rpc/rest_client.py +++ b/freqtrade/rpc/rest_client.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python3. """ Simple command line client into RPC commands Can be used as an alternate to Telegram diff --git a/freqtrade/rpc/rpc_manager.py b/freqtrade/rpc/rpc_manager.py index 2dfb119fe..ef71ff3a9 100644 --- a/freqtrade/rpc/rpc_manager.py +++ b/freqtrade/rpc/rpc_manager.py @@ -1,5 +1,5 @@ """ -This module contains class to manage RPC communications (Telegram, Slack, ...) +This module contains class to manage RPC communications (Telegram, Slack, ....) """ from typing import Any, List import logging