Commit Graph

142 Commits

Author SHA1 Message Date
creslinux
c227bb3139 Moved routes that do not need access to rpc.rpc self into their own
common file.

This is to reduce file size and separate api server routes with
privilege to access rpc.rpc defs and those that do not need access,
so should not.
2018-06-23 14:04:15 +00:00
creslinux
3fb680b3b4 removed change to cleanup() in api_server.py 2018-06-23 12:38:04 +00:00
creslinux
eedcb64962 Added api server shutdown function, and exposed on HTTP as /stop_api url
This will stop the running app gracefully - processing current api calls
then shutting the werkzueg (run) listening server.

Have also called this from the cleanup placeholder.
I'm not sure this is what is intended by cleanup def.
By which I mean there may be a thread left running with no app within -
not sure how to check this just yet.

tidied excessive logging.
2018-06-23 12:17:00 +00:00
creslinux
839d513bb8 Added api server shutdown function, and exposed on HTTP as /stop_api url
This will stop the running app gracefully - processing current api calls
then shutting the werkzueg (run) listening server.

Have also called this from the cleanup placeholder.
I'm not sure this is what is intended by cleanup def.
By which I mean there may be a thread left running with no app within -
not sure how to check this just yet.

tidied excessive logging.
2018-06-23 11:53:09 +00:00
creslinux
c72397936e Updated def comments to be __docstring__ compatible 2018-06-23 09:48:51 +00:00
creslinux
6c3ea7c5f9 flake 8 fix 2018-06-23 09:22:25 +00:00
creslinux
5cda78bf32 moved default page "/" index into self_register_other()
out of the block of URLs that call rpc.rcp functionality.
2018-06-23 09:19:34 +00:00
creslinux
d0d128d203 Moved registering application urls out of the run def
and into their own

Added 404 handling

Split registration of URLs that use rpc.rpc and others into
own def. Seems logical to be able to register separately for later use.
2018-06-23 09:08:39 +00:00
gcarq
418359ac9a Merge branch 'develop' of https://github.com/freqtrade/freqtrade into feature/flask-rest 2018-06-23 09:34:32 +02:00
gcarq
77d53b0b7c remove _rpc_status_table and reuse _rpc_status instead 2018-06-23 09:28:13 +02:00
gcarq
4aab55d27b api_server: fix flake8 warnings and implement missing methods 2018-06-23 09:27:28 +02:00
gcarq
a2426c3854 refactor _rpc_balance 2018-06-22 04:08:51 +02:00
gcarq
8d54a20122 return dict from _rpc_status and handle rendering in module impl 2018-06-22 03:54:10 +02:00
gcarq
ec4e6272d0 remove markdown formatting from exception string 2018-06-22 03:37:19 +02:00
gcarq
ada87ba3a0 convert start, stop and reload_conf to return a dict 2018-06-22 03:32:45 +02:00
gcarq
556d507317 move endpoint definitions to class scope 2018-06-22 02:56:10 +02:00
gcarq
8ecfbc2a35 make rpc modules optional 2018-06-22 02:55:49 +02:00
gcarq
814894da7b fix flake8 warnings 2018-06-22 02:55:27 +02:00
xmatthias
2b099a89e4 fix styling issues 2018-06-17 23:38:07 +02:00
xmatthias
63b568989a Fix rpc for exchange objectify 2018-06-17 23:38:07 +02:00
creslinux
05226f6def Moved from decorators to app.add_url_rule
This has the benefit of creating a label which may be helpful if later
refactoring.

This change misses the main thrust of requests from both Gcarq and Shusso to
better layout the code

Im running into a challenge with 'self' not being available, or able to be
passed in either to decorators or view_func

This may simply be how I've instantiated an RPC in the wuperwrap or im within a thread
 - my very limited exposure to programming is at play! After moving code around
 lots of ways to no success and google not being helpful im committing for further feeback
2018-06-15 09:14:17 +00:00
creslinux
7f46411966 Merge remote-tracking branch 'origin/flask_rest' into flask_rest 2018-06-14 20:21:42 +00:00
creslinux
40db83c24c Added json validation of formats to check IPv4
refactored files and calls to be api_server
worked down satisfying review comments of last commit
2018-06-14 20:19:15 +00:00
Michael Egger
f21ef07910
Merge branch 'develop' into flask_rest 2018-06-14 18:10:04 +02:00
creslinux
7caf8a46d4 Updated
Stop and start calls added
Along with refactoring to base line and use decorators.
Also modules loaded optionally if enabled in config or not
binds to ip / port set from config.json with warning if not localhost

TODO:
 - use argparse in client, and generally clean client up
 - create unit test
 - documentation
 - extend to other RCP commands, after feedback
2018-06-14 15:44:52 +00:00
creslinux
9bbc186b16 Updated
Stop and start calls added
Along with refactoring to base line and use decorators.
Also modules loaded optionally if enabled in config or not
binds to ip / port set from config.json with warning if not localhost

TODO:
 - use argparse in client, and generally clean client up
 - create unit test
 - documentation
 - extend to other RCP commands, after feedback
2018-06-14 15:44:12 +00:00
creslinux
c2742f0b01 Merge remote-tracking branch 'origin/flask_rest' into flask_rest 2018-06-14 15:41:32 +00:00
creslinux
fb60f684f7 Updated
Stop and start calls added
Along with refactoring to base line and use decorators.
Also modules loaded optionally if enabled in config or not
binds to ip / port set from config.json with warning if not localhost

TODO:
 - use argparse in client, and generally clean client up
 - create unit test
 - documentation
 - extend to other RCP commands, after feedback
2018-06-14 15:38:26 +00:00
creslin
faf0a4973d
Update rest_client.py 2018-06-13 22:41:43 +00:00
creslinux
6bb1ad288e 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"
    ]
]
2018-06-13 22:26:21 +00:00
creslinux
e5e64a7035 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"
    ]
]
2018-06-13 22:18:49 +00:00
gcarq
46080f5168 define _rpc_reload_conf as private method 2018-06-13 15:29:27 +02:00
gcarq
e14c9e2090 fix potential cleanup issue 2018-06-13 12:21:54 +02:00
gcarq
83eb7a0a9d adjust logging a bit and add some comments 2018-06-13 12:21:54 +02:00
gcarq
6c1bb7983b rpc: make freqtrade a private variable 2018-06-13 12:21:54 +02:00
gcarq
34e10a145c remove Telegram.is_enabled() because RPCManager manages lifecycles 2018-06-13 12:21:54 +02:00
gcarq
3787dad212 don't import python-telegram-bot at runtime if disabled in config 2018-06-13 12:21:54 +02:00
gcarq
4048859912 rpc: remove tuple return madness 2018-06-13 12:21:54 +02:00
gcarq
cddb062db5 save rpc instances only in registered_modules, add some abstract methods 2018-06-13 12:21:54 +02:00
Janne Sinivirta
c46e50864b
Merge pull request #886 from freqtrade/feature/reload-conf
Reload bot config without restarting
2018-06-11 10:47:00 +03:00
gcarq
0b5d21f32a implement bot reconfiguration and expose it to telegram 2018-06-09 04:29:48 +02:00
creslinux
efbeabf141 Added Local RPC client
- added only "Daily" call so far, submitting for early review/feedback

This depends on zerorpc as a requirement.
simple examples here:
http://www.zerorpc.io/

Installed with pip3 install zerorpc

localRCP is enabled/disabled from within config.json
e.g
    "localrpc": {
        "enabled": true
       },

The server is enabled from within existing rpc manager
and makes use of the existing superclass (RPC)

Though making use of the existing hardwork done in rpc.py
It *should be easy to add the other Telegram calls into local_rpy_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 script

As example, from cmdline for last 3 days Daily

/Users/creslin/PycharmProjects/freqtrade_new/.env/bin/zerorpc tcp://127.0.0.1:4242 daily 3
connecting to "tcp://127.0.0.1:4242"
False
('[\n'
 '    [\n'
 '        "2018-06-08",\n'
 '        "0.00000000 BTC",\n'
 '        "0.000 USDT",\n'
 '        "0 trade"\n'
 '    ],\n'
 '    [\n'
 '        "2018-06-07",\n'
 '        "0.00000000 BTC",\n'
 '        "0.000 USDT",\n'
 '        "0 trade"\n'
 '    ],\n'
 '    [\n'
 '        "2018-06-06",\n'
 '        "0.00000000 BTC",\n'
 '        "0.000 USDT",\n'
 '        "0 trade"\n'
 '    ]\n'
 ']')

Programitcally this would be:
import zerorpc

c = zerorpc.Client()
c.connect("tcp://127.0.0.1:4242")

for item in c.daily(3):
    print item
2018-06-08 18:35:01 +00:00
gcarq
61b2373dd1 flush db connection after forcesell 2018-06-08 02:35:10 +02:00
xmatthias
0e699b87af don't sum percentage, but use mean instead (aligned to backtesting) 2018-06-07 20:43:28 +02:00
xmatthias
50fc5f91ca Merge branch 'develop' into mypy_typecheck 2018-06-03 10:35:56 +02:00
xmatthias
6fc21e30e5 remove unused import 2018-06-02 13:52:55 +02:00
xmatthias
4a322abd4d Typecheck improvements 2018-06-02 13:44:05 +02:00
xmatthias
69006b8fe8 flake8 2018-05-31 21:08:26 +02:00
xmatthias
0d251cbfdd rpc type hints 2018-05-31 20:55:26 +02:00
xmatthias
4733aad7ff mypy_typing 2018-05-31 20:54:37 +02:00