|
|
@ -8,6 +8,7 @@ import sys |
|
|
|
from threading import Thread |
|
|
|
import time |
|
|
|
import traceback |
|
|
|
import csv |
|
|
|
from decimal import Decimal |
|
|
|
from functools import partial |
|
|
|
|
|
|
@ -43,6 +44,13 @@ class ExchangeBase(PrintError): |
|
|
|
headers={'User-Agent' : 'Electrum'}) |
|
|
|
return response.json() |
|
|
|
|
|
|
|
def get_csv(self, site, get_string): |
|
|
|
url = "".join([self.protocol(), '://', site, get_string]) |
|
|
|
response = requests.request('GET', url, |
|
|
|
headers={'User-Agent' : 'Electrum'}) |
|
|
|
reader = csv.DictReader(response.content.split('\n')) |
|
|
|
return list(reader) |
|
|
|
|
|
|
|
def name(self): |
|
|
|
return self.__class__.__name__ |
|
|
|
|
|
|
@ -90,6 +98,17 @@ class BitcoinAverage(ExchangeBase): |
|
|
|
return dict([(r, Decimal(json[r]['last'])) |
|
|
|
for r in json if r != 'timestamp']) |
|
|
|
|
|
|
|
def history_ccys(self): |
|
|
|
return ['AUD', 'BRL', 'CAD', 'CHF', 'CNY', 'EUR', 'GBP', 'IDR', 'ILS', |
|
|
|
'MXN', 'NOK', 'NZD', 'PLN', 'RON', 'RUB', 'SEK', 'SGD', 'USD', |
|
|
|
'ZAR'] |
|
|
|
|
|
|
|
def historical_rates(self, ccy): |
|
|
|
history = self.get_csv('api.bitcoinaverage.com', |
|
|
|
"/history/%s/per_day_all_time_history.csv" % ccy) |
|
|
|
return dict([(h['datetime'][:10], h['average']) |
|
|
|
for h in history]) |
|
|
|
|
|
|
|
class BitcoinVenezuela(ExchangeBase): |
|
|
|
def get_rates(self, ccy): |
|
|
|
json = self.get_json('api.bitcoinvenezuela.com', '/') |
|
|
|