-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
107 lines (90 loc) · 2.52 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import requests, json, time
import os
if os.name == 'posix':
import notify2 as nlib
else:
from win10toast import ToastNotifier
#toaster = ToastNotifier()
# toaster.show_toast("Hello World!!!",
# "Python is 10 seconds awsm!",
# icon_path="custom.ico",
# duration=10)
# toaster.show_toast("Hello World!!!",
# "Python is awsm by default!")
def show_message_windows(s):
toaster.show_toast('Arbitrage alert', s)
def init_windows():
toaster = ToastNotifier()
def init_linux():
nlib.init('Arbitrage-Tracker')
def show_message_linux(s):
notifn = nlib.Notification('Arbitrage alert', s, 'notification-message-im')
notifn.show()
def show_message(s):
print os.name
if os.name == 'posix':
show_message_linux(s)
else:
show_message_windows(s)
def get_ethex_price():
URL = 'https://api.ethexindia.com/ticker/'
r = requests.get(URL)
r = json.loads(r.text)
return r
def get_koinex_price():
URL = 'https://koinex.in/api/ticker'
r = requests.get(URL)
r = json.loads(r.text)
return r
def check_opp():
ethex = get_ethex_price()
koinex = get_koinex_price()
e_price = ethex['last_traded_price']
k_price = koinex['prices']['ETH']
e_price = float(e_price)
k_price = float(k_price)
print '='*60
print ' ', k_price
print "- %s (%s + %s)" %(e_price * 1.01, e_price, 0.01 * e_price)
diff = k_price - (1.01 * e_price)
print '-'*60
print ' ', diff
if diff > 100:
show_message("Arbitrage opportunity worth %s" % diff)
def get_ethex_price():
URL = 'https://api.ethexindia.com/ticker/'
r = requests.get(URL)
r = json.loads(r.text)
return r
def get_koinex_price():
URL = 'https://koinex.in/api/ticker'
r = requests.get(URL)
r = json.loads(r.text)
return r
def check_opp():
ethex = get_ethex_price()
koinex = get_koinex_price()
e_price = ethex['last_traded_price']
k_price = koinex['prices']['ETH']
e_price = float(e_price)
k_price = float(k_price)
print '='*60
print ' ', k_price
print "- %s (%s + %s)" %(e_price * 1.01, e_price, 0.01 * e_price)
diff = k_price - (1.01 * e_price)
print '-'*60
print ' ', diff
if diff > 800:
show_message("Arbitrage opportunity worth %s" % diff)
def init():
if os.name == 'posix':
init_linux()
else:
init_windows()
def main_loop():
while True:
check_opp()
time.sleep(60)
if __name__ == '__main__':
init()
main_loop()