exchange_rate: change default provider to CoinGecko

closes #5188
This commit is contained in:
SomberNight 2019-03-22 16:55:57 +01:00
parent 5cbf54d23a
commit c23e949848
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -23,7 +23,7 @@ from .simple_config import SimpleConfig
DEFAULT_ENABLED = False
DEFAULT_CURRENCY = "EUR"
DEFAULT_EXCHANGE = "BitcoinAverage" # default exchange should ideally provide historical rates
DEFAULT_EXCHANGE = "CoinGecko" # default exchange should ideally provide historical rates
# See https://en.wikipedia.org/wiki/ISO_4217
@ -142,23 +142,16 @@ class ExchangeBase(PrintError):
rates = await self.get_rates('')
return sorted([str(a) for (a, b) in rates.items() if b is not None and len(a)==3])
class BitcoinAverage(ExchangeBase):
# note: historical rates used to be freely available
# but this is no longer the case. see #5188
async def get_rates(self, ccy):
json = await self.get_json('apiv2.bitcoinaverage.com', '/indices/global/ticker/short')
return dict([(r.replace("BTC", ""), Decimal(json[r]['last']))
for r in json if r != 'timestamp'])
def history_ccys(self):
# BitcoinAverage seems to have historical data for all ccys it supports
return CURRENCIES[self.name()]
async def request_history(self, ccy):
history = await self.get_csv('apiv2.bitcoinaverage.com',
"/indices/global/history/BTC%s?period=alltime&format=csv" % ccy)
return dict([(h['DateTime'][:10], h['Average'])
for h in history])
class Bitcointoyou(ExchangeBase):