-
Notifications
You must be signed in to change notification settings - Fork 0
/
price_call.py
38 lines (29 loc) · 971 Bytes
/
price_call.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
import json
import urllib2
class PriceCall:
def __init__(self, params):
self.currencypair = params['currencypair']
if self.currencypair == 'dogebtc':
self.price = self.dogebtc()
def __str__(self):
return str(self.price)
def price(self):
#check time
return self.price
def dogebtc(self):
return self.get_data('DOGE/BTC')
def get_data(self, pair):
price = int
set = False
while bool(set) == False:
try:
data = json.load(urllib2.urlopen("http://pubapi.cryptsy.com/api.php?method=marketdatav2"))['return']
price = data['markets'][pair]['lasttradeprice']
set = True
break
except:
print str(Exception)
continue
return price
price = PriceCall({'currencypair':'dogebtc'})
print price