Browse Source

exchange_rate: change default provider to CoinGecko

closes #5188
regtest_lnd
SomberNight 6 years ago
parent
commit
c23e949848
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 15
      electrum/exchange_rate.py

15
electrum/exchange_rate.py

@ -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):

Loading…
Cancel
Save