From 7de1c604c6403ba065d76425950cf07e3c78df94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arian=20Ventura=20Rodr=C3=ADguez?= Date: Fri, 23 Sep 2022 15:27:00 -0400 Subject: [PATCH] Add yadio.io api to exchange rate --- electrum/currencies.json | 91 +++++++++++++++++++++++++++++++++++++++ electrum/exchange_rate.py | 9 ++++ 2 files changed, 100 insertions(+) diff --git a/electrum/currencies.json b/electrum/currencies.json index 342708d71..78970b610 100644 --- a/electrum/currencies.json +++ b/electrum/currencies.json @@ -900,5 +900,96 @@ ], "Walltime": [ "BRL" + ], + "Yadio": [ + "AED", + "ANG", + "AOA", + "ARS", + "AUD", + "AZN", + "BDT", + "BHD", + "BMD", + "BOB", + "BRL", + "BTC", + "BWP", + "BYN", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUP", + "CZK", + "DKK", + "DOP", + "DZD", + "EGP", + "ETB", + "EUR", + "GBP", + "GEL", + "GHS", + "GTQ", + "HKD", + "HNL", + "HUF", + "IDR", + "ILS", + "INR", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KRW", + "KZT", + "LBP", + "LKR", + "MAD", + "MLC", + "MXN", + "MYR", + "NAD", + "NGN", + "NOK", + "NPR", + "NZD", + "PAB", + "PEN", + "PHP", + "PKR", + "PLN", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "SAR", + "SEK", + "SGD", + "THB", + "TND", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "UYU", + "UZS", + "VES", + "VND", + "XAF", + "XAG", + "XAU", + "XOF", + "XPT", + "ZAR" ] } diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py index c9a7cc6d5..f779a332f 100644 --- a/electrum/exchange_rate.py +++ b/electrum/exchange_rate.py @@ -181,6 +181,15 @@ class ExchangeBase(Logger): return Decimal('NaN') return Decimal(rate) +class Yadio(ExchangeBase): + + async def get_currencies(self): + dicts = await self.get_json('api.yadio.io', '/currencies') + return list(dicts.keys()) + + async def get_rates(self, ccy: str) -> Mapping[str, Optional[Decimal]]: + json = await self.get_json('api.yadio.io', '/rate/%s/BTC' % ccy) + return {ccy: to_decimal(json['rate'])} class BitcoinAverage(ExchangeBase): # note: historical rates used to be freely available