-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
55 lines (40 loc) · 1.34 KB
/
Copy pathapp.py
File metadata and controls
55 lines (40 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import configparser
from flask import Flask
from logger import logger
from paths import Paths
from trading_service import TradingService
app = Flask(__name__)
service = TradingService()
@app.route("/")
def index():
return 'Hello Coin Bot!'
@app.route("/resume")
def resume():
try:
service.resume()
except Exception as e:
return str(e)
return "Server resumed"
@app.route("/pause")
def pause():
try:
service.pause()
except Exception as e:
return str(e)
return "Server stopped"
if __name__ == '__main__':
config = configparser.ConfigParser()
config.read(Paths.CONFIG)
host = config['server']['host']
port = config['server'].getint('port')
currency = config['server']['currency']
budget = config['server'].getint('budget')
interval = config['server'].getint('interval')
criteria = config['server'].getfloat('criteria')
logger.info('Currency: {}, Budget: {:,}, Interval: {} mins, Criteria: {}%'.format(
currency, budget, interval, criteria))
prediction_debug = config['debug'].getboolean('prediction')
payment_debug = config['debug'].getboolean('payment')
logger.info('Debug: prediction %s, payment %s', prediction_debug, payment_debug)
service.start(currency, budget=budget, mins=interval, criteria=criteria)
app.run(host, port, debug=False)