fix exchange_rate in kivy
This commit is contained in:
@@ -105,9 +105,6 @@ class HistoryScreen(CScreen):
|
|||||||
d = LabelDialog(_('Enter Transaction Label'), text, callback)
|
d = LabelDialog(_('Enter Transaction Label'), text, callback)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def get_history_rate(self, btc_balance, timestamp):
|
|
||||||
date = timestamp_to_datetime(timestamp)
|
|
||||||
return run_hook('historical_value_str', btc_balance, date)
|
|
||||||
|
|
||||||
def parse_history(self, items):
|
def parse_history(self, items):
|
||||||
for item in items:
|
for item in items:
|
||||||
@@ -125,7 +122,6 @@ class HistoryScreen(CScreen):
|
|||||||
time_str = _('pending')
|
time_str = _('pending')
|
||||||
icon = "atlas://gui/kivy/theming/light/unconfirmed"
|
icon = "atlas://gui/kivy/theming/light/unconfirmed"
|
||||||
elif conf < 6:
|
elif conf < 6:
|
||||||
time_str = '' # add new to fix error when conf < 0
|
|
||||||
conf = max(1, conf)
|
conf = max(1, conf)
|
||||||
icon = "atlas://gui/kivy/theming/light/clock{}".format(conf)
|
icon = "atlas://gui/kivy/theming/light/clock{}".format(conf)
|
||||||
else:
|
else:
|
||||||
@@ -137,9 +133,10 @@ class HistoryScreen(CScreen):
|
|||||||
label = _('Pruned transaction outputs')
|
label = _('Pruned transaction outputs')
|
||||||
is_default_label = False
|
is_default_label = False
|
||||||
|
|
||||||
quote_currency = 'USD'
|
date = timestamp_to_datetime(timestamp)
|
||||||
rate = self.get_history_rate(value, timestamp)
|
rate = run_hook('history_rate', date)
|
||||||
quote_text = "..." if rate is None else "{0:.3} {1}".format(rate, quote_currency)
|
if self.app.fiat_unit:
|
||||||
|
quote_text = "..." if rate is None else "{0:.3} {1}".format(Decimal(value) / 100000000 * Decimal(rate), self.app.fiat_unit)
|
||||||
|
|
||||||
yield (conf, icon, time_str, label, value, tx_hash, quote_text)
|
yield (conf, icon, time_str, label, value, tx_hash, quote_text)
|
||||||
|
|
||||||
|
|||||||
@@ -341,13 +341,18 @@ class FxPlugin(BasePlugin, ThreadJob):
|
|||||||
return _("No data")
|
return _("No data")
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def historical_value_str(self, satoshis, d_t):
|
def history_rate(self, d_t):
|
||||||
rate = self.exchange.historical_rate(self.ccy, d_t)
|
rate = self.exchange.historical_rate(self.ccy, d_t)
|
||||||
# Frequently there is no rate for today, until tomorrow :)
|
# Frequently there is no rate for today, until tomorrow :)
|
||||||
# Use spot quotes in that case
|
# Use spot quotes in that case
|
||||||
if rate is None and (datetime.today().date() - d_t.date()).days <= 2:
|
if rate is None and (datetime.today().date() - d_t.date()).days <= 2:
|
||||||
rate = self.exchange.quotes.get(self.ccy)
|
rate = self.exchange.quotes.get(self.ccy)
|
||||||
self.history_used_spot = True
|
self.history_used_spot = True
|
||||||
|
return rate
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def historical_value_str(self, satoshis, d_t):
|
||||||
|
rate = self.history_rate(d_t)
|
||||||
return self.value_str(satoshis, rate)
|
return self.value_str(satoshis, rate)
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
|
|||||||
Reference in New Issue
Block a user