-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
185 lines (101 loc) · 4.33 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
from requests import Request, Session
import json
import api_key
url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest'
headers = {'Accepts':'application/json',
'X-CMC_PRO_API_KEY': api_key.KEY}
session = Session()
session.headers.update(headers)
class main:
def __init__(self):
self.eos_target = 87.00
self.xrp_target = 9.55
self.bch_target = 9000.00
self.dash_target = 2800.00
def getTarget(self):
return self.eos_target
return self.xrp_target
return self.bch_target
return self.dash_target
#""" Evaluates if the desired target is still greater than the current price. """
def __gt__(self):
if self.eos_target > EOSUSD:
print('EOS target is not close.')
else:
print('EOS TARGET IS CLOSE!')
#------------------------------------------------#
if self.xrp_target > XRPUSD:
print('XRP target is not close.')
else:
print('XRP TARGET IS CLOSE!')
#------------------------------------------------#
if self.bch_target > BCHUSD:
print('BCH target is not close.')
else:
print('BCH TARGET IS CLOSE!')
#------------------------------------------------#
if self.dash_target > DASHUSD:
print('DASH target is not close.')
else:
print('DASH TARGET IS CLOSE!')
#""" Evaluates the highest remaining percentage of profit left in a particular asset based on the predetermined target. """
def percentEval(self):
if self.eos_target and self.xrp_target and self.bch_target and self.dash_target != 0:
eos_margin = (abs(self.eos_target - EOSUSD) / EOSUSD) * 100
xrp_margin = (abs(self.xrp_target - XRPUSD) / XRPUSD) * 100
bch_margin = (abs(self.bch_target - BCHUSD) / BCHUSD) * 100
dash_margin = (abs(self.dash_target - DASHUSD) / DASHUSD) * 100
if eos_margin > max(xrp_margin, bch_margin, dash_margin):
print(str("{0:.2f}".format(eos_margin)) + '% on EOS')
elif xrp_margin > max(eos_margin, bch_margin, dash_margin):
print(str("{0:.2f}".format(xrp_margin)) + '% on XRP')
elif bch_margin > max(eos_margin, xrp_margin, dash_margin):
print(str("{0:.2f}".format(bch_margin)) + '% on BCH')
elif dash_margin > max(eos_margin, xrp_margin, bch_margin):
print(str("{0:.2f}".format(dash_margin)) + '% on DASH')
else:
return "By some anomaly you have lost 100% on one of your assets or wanted something to go to zero."
#""" Fn's to get asset price data """
def getEosPrice():
parameters = {
#Changeable#
'symbol':'eos',
'convert':'USD'
}
assetData = session.get(url, params=parameters)
###
price = json.loads(assetData.text)['data']['EOS']['quote']['USD']['price']
return price
EOSUSD = getEosPrice()
#------------------------------------------------------------------------------#
def getXrpPrice():
parameters = {
'symbol':'xrp',
'convert':'USD'
}
assetData = session.get(url, params=parameters)
price = json.loads(assetData.text)['data']['XRP']['quote']['USD']['price']
return price
XRPUSD = getXrpPrice()
#------------------------------------------------------------------------------#
def getBchPrice():
parameters = {
'symbol':'bch',
'convert':'USD'
}
assetData = session.get(url, params=parameters)
price = json.loads(assetData.text)['data']['BCH']['quote']['USD']['price']
return price
BCHUSD = getBchPrice()
#------------------------------------------------------------------------------#
def getDashPrice():
parameters = {
'symbol':'dash',
'convert':'USD'
}
assetData = session.get(url, params=parameters)
price = json.loads(assetData.text)['data']['DASH']['quote']['USD']['price']
return price
DASHUSD = getDashPrice()
r = main()
r.percentEval()