add BitcoinAverage to exchange_rate.py/currensies.json

This commit is contained in:
zebra-lucky 2018-06-09 16:23:40 +03:00
parent e196cc205b
commit 3d84bd8441
2 changed files with 25 additions and 2 deletions

View File

@ -1,4 +1,9 @@
{
"BitcoinAverage": [
"USD",
"EUR",
"PLN"
],
"Bittrex": [
"BTC"
],

View File

@ -26,8 +26,8 @@ CCY_PRECISIONS = {'BHD': 3, 'BIF': 0, 'BYR': 0, 'CLF': 4, 'CLP': 0,
'BTC': 8}
DEFAULT_EXCHANGE = 'Bittrex'
DEFAULT_CCY = 'BTC'
DEFAULT_EXCHANGE = 'BitcoinAverage'
DEFAULT_CCY = 'USD'
class ExchangeBase(PrintError):
@ -121,6 +121,24 @@ class ExchangeBase(PrintError):
return sorted([str(a) for (a, b) in rates.items() if b is not None and len(a)==3])
class BitcoinAverage(ExchangeBase):
def get_rates(self, ccy):
json = self.get_json('apiv2.bitcoinaverage.com',
'/indices/local/ticker/ZEC%s' % ccy)
return {ccy: Decimal(json['last'])}
def history_ccys(self):
return ['USD', 'EUR', 'PLN']
def request_history(self, ccy):
history = self.get_json('apiv2.bitcoinaverage.com',
"/indices/local/history/ZEC%s"
"?period=alltime&format=json" % ccy)
return dict([(h['time'][:10], h['average']) for h in history])
class Bittrex(ExchangeBase):
def get_rates(self, ccy):
json = self.get_json('bittrex.com',