update historical winkdex api

This commit is contained in:
Michael Wozniak 2014-07-22 17:28:37 -04:00
parent a72bc5a44a
commit 9ae30533ca
1 changed files with 6 additions and 4 deletions

View File

@ -423,7 +423,7 @@ class Plugin(BasePlugin):
return
elif cur_exchange == "Winkdex":
try:
resp_hist = self.exchanger.get_json('winkdex.com', "/static/data/0_86400_730.json")['prices']
resp_hist = self.exchanger.get_json('winkdex.com', "/api/v0/series?start_time=1342915200")['series'][0]['results']
except Exception:
return
elif cur_exchange == "BitcoinVenezuela":
@ -464,12 +464,14 @@ class Plugin(BasePlugin):
except KeyError:
tx_USD_val = "%.2f %s" % (self.btc_rate * Decimal(str(tx_info['value']))/100000000 , "USD")
elif cur_exchange == "Winkdex":
tx_time_str = int(tx_time) - (int(tx_time) % (60 * 60 * 24))
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d') + "T16:00:00-04:00"
try:
tx_rate = resp_hist[[x['x'] for x in resp_hist].index(tx_time_str)]['y']
tx_USD_val = "%.2f %s" % (Decimal(tx_info['value']) / 100000000 * Decimal(tx_rate), "USD")
tx_rate = resp_hist[[x['timestamp'] for x in resp_hist].index(tx_time_str)]['price']
tx_USD_val = "%.2f %s" % (Decimal(tx_info['value']) / 100000000 * Decimal(tx_rate)/Decimal("100.0"), "USD")
except ValueError:
tx_USD_val = "%.2f %s" % (self.btc_rate * Decimal(tx_info['value'])/100000000 , "USD")
except KeyError:
tx_USD_val = _("No data")
elif cur_exchange == "BitcoinVenezuela":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d')
try: