-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (51 loc) · 1.52 KB
/
main.py
File metadata and controls
56 lines (51 loc) · 1.52 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
56
import sys, os, asyncio, time, ast
import tools
import price_feeds
import marketMaker
import orders
import contracts
import analytics
client = {}
marketID = None
async def main():
if len(sys.argv) > 2 and sys.argv[2] == "analytics":
await analytics.start()
else:
x = True
while x is True:
try:
net = 'm'
if sys.argv == 2 and sys.argv[2] == "fuji":
net = 'fuji'
await marketMaker.start(net)
except asyncio.CancelledError:
print("asyncio.CancelledError")
await asyncio.sleep(15)
continue
except Exception as error:
print("main error:",error)
await asyncio.sleep(15)
continue
except KeyboardInterrupt:
print("KeyboardInterrupt")
print("CANCELLING ORDERS AND SHUTTING DOWN")
x = False
contracts.status = False
await orders.cancelAllOrders(marketMaker.pairStr, True)
# Start and run until complete
# loop = asyncio.get_event_loop()
# task = loop.create_task(main())
# Run until a certain condition or indefinitely
try:
asyncio.run(main())
except:
print("FINISHED")
# except KeyboardInterrupt:
# # Handle other shutdown signals here
# try:
# print("CANCELLING ORDERS AND SHUTTING DOWN")
# loop = asyncio.get_event_loop()
# task = loop.create_task(orders.cancelAllOrders(marketMaker.pairStr,True))
# loop.run_until_complete(task)
# except:
# print("Stopping. Please confirm that orders have been cancelled.")