1
0

exchange_rate: fix #5487

This commit is contained in:
SomberNight
2019-07-04 19:55:03 +02:00
parent 650225e238
commit 93d68a4361

View File

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