Update exchange rate plugin for Winkdex

updated exchange rate BTC price for Winkdex API that was officially published
This commit is contained in:
Michael Wozniak 2014-07-22 17:06:23 -04:00
parent 068609b4a6
commit a72bc5a44a
1 changed files with 4 additions and 7 deletions

View File

@ -48,7 +48,7 @@ class Exchanger(threading.Thread):
def get_json(self, site, get_string): def get_json(self, site, get_string):
try: try:
connection = httplib.HTTPSConnection(site) connection = httplib.HTTPSConnection(site)
connection.request("GET", get_string) connection.request("GET", get_string, headers={"User-Agent":"Electrum"})
except Exception: except Exception:
raise raise
resp = connection.getresponse() resp = connection.getresponse()
@ -123,16 +123,13 @@ class Exchanger(threading.Thread):
def update_wd(self): def update_wd(self):
try: try:
winkresp = self.get_json('winkdex.com', "/static/data/0_600_288.json") winkresp = self.get_json('winkdex.com', "/api/v0/price")
####could need nonce value in GET, no Docs available
except Exception: except Exception:
return return
quote_currencies = {"USD": 0.0} quote_currencies = {"USD": 0.0}
####get y of highest x in "prices" usdprice = decimal.Decimal(str(winkresp["price"]))/decimal.Decimal("100.0")
lenprices = len(winkresp["prices"])
usdprice = winkresp["prices"][lenprices-1]["y"]
try: try:
quote_currencies["USD"] = decimal.Decimal(str(usdprice)) quote_currencies["USD"] = usdprice
with self.lock: with self.lock:
self.quote_currencies = quote_currencies self.quote_currencies = quote_currencies
except KeyError: except KeyError: