From 93d68a43611ec22369206f3edb03030b1d6fcb3e Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 4 Jul 2019 19:55:03 +0200 Subject: [PATCH] exchange_rate: fix #5487 --- electrum/exchange_rate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py index fcd3b9f1d..d19a7dcd0 100644 --- 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)