use Decimal for exchange rates
This commit is contained in:
@@ -488,7 +488,7 @@ class FxThread(ThreadJob):
|
|||||||
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
|
return Decimal(rate) if rate is not None else None
|
||||||
|
|
||||||
def historical_value_str(self, satoshis, d_t):
|
def historical_value_str(self, satoshis, d_t):
|
||||||
rate = self.history_rate(d_t)
|
rate = self.history_rate(d_t)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import traceback
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -915,7 +916,6 @@ class Abstract_Wallet(PrintError):
|
|||||||
return h2
|
return h2
|
||||||
|
|
||||||
def export_history(self, domain=None, from_timestamp=None, to_timestamp=None, fx=None, show_addresses=False):
|
def export_history(self, domain=None, from_timestamp=None, to_timestamp=None, fx=None, show_addresses=False):
|
||||||
from decimal import Decimal
|
|
||||||
from .util import format_time, format_satoshis, timestamp_to_datetime
|
from .util import format_time, format_satoshis, timestamp_to_datetime
|
||||||
h = self.get_history(domain)
|
h = self.get_history(domain)
|
||||||
out = []
|
out = []
|
||||||
@@ -1607,7 +1607,7 @@ class Abstract_Wallet(PrintError):
|
|||||||
tx = self.transactions[txid]
|
tx = self.transactions[txid]
|
||||||
out_value = sum([ (value if not self.is_mine(address) else 0) for otype, address, value in tx.outputs() ])
|
out_value = sum([ (value if not self.is_mine(address) else 0) for otype, address, value in tx.outputs() ])
|
||||||
try:
|
try:
|
||||||
return out_value/1e8 * (price_func(timestamp) - self.average_price(tx, price_func))
|
return out_value/Decimal(COIN) * (price_func(timestamp) - self.average_price(tx, price_func))
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user