-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.py
45 lines (40 loc) · 1.39 KB
/
app.py
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
import helper
import logging
import os
import manager
def setLog(simMode):
if simMode == 0: # external import data
filename_ = 'simlog_ext.txt'
elif simMode == 1: # realtime simulating
filename_ = 'simlog.txt'
else: # trading
filename_ = 'log.txt'
format_ = '%(asctime)s %(name)s %(levelname)s %(message)s'
logging.basicConfig(level=logging.DEBUG,
format=format_,
datefmt='%Y-%m-%d %H:%M:%S',
filename=filename_
)
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# set a format which is simpler for console use
formatter = logging.Formatter(format_, datefmt='%Y-%m-%d %H:%M:%S')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)
logging.getLogger("requests").setLevel(logging.WARNING)
'''Main'''
os.system('cls')
print "BTC arbitrage bot starting"
simMode = 2 # 0 for external import data, 1 for real time tracking without trading, 2 for trading
setLog(simMode)
config = helper.Config()
arg = {"simMode": simMode, "config": config}
botmanager = manager.Manager(arg)
if simMode == 0:
botmanager.runLoopSim()
else:
# botmanager.runOnce()
botmanager.runLoop()