commit 93d68a43611ec22369206f3edb03030b1d6fcb3e
parent 650225e238a1a9db07d713cf202f0ed1e51a92e7
Author: SomberNight <somber.night@protonmail.com>
Date: Thu, 4 Jul 2019 19:55:03 +0200
exchange_rate: fix #5487
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py
@@ -563,7 +563,8 @@ class FxThread(ThreadJob):
self.logger.info(f"using exchange {name}")
if self.config_exchange() != name:
self.config.set_key('use_exchange', name, True)
- self.exchange = class_(self.on_quotes, self.on_history)
+ assert issubclass(class_, ExchangeBase), f"unexpected type {class_} for {name}"
+ self.exchange = class_(self.on_quotes, self.on_history) # type: ExchangeBase
# A new exchange means new fx quotes, initially empty. Force
# a quote refresh
self.trigger_update()
@@ -616,6 +617,8 @@ class FxThread(ThreadJob):
# Use spot quotes in that case
if rate == 'NaN' and (datetime.today().date() - d_t.date()).days <= 2:
rate = self.exchange.quotes.get(self.ccy, 'NaN')
+ if rate is None:
+ rate = 'NaN'
self.history_used_spot = True
return Decimal(rate)