diff --git a/ibkr_report/exchangerates.py b/ibkr_report/exchangerates.py index 8fa69d59..6e9e5f28 100644 --- a/ibkr_report/exchangerates.py +++ b/ibkr_report/exchangerates.py @@ -111,15 +111,14 @@ def download_official_rates(self, url: str) -> None: def get_rate(self, currency_from: str, currency_to: str, date_str: str) -> Decimal: """Exchange rate between two currencies on a given day.""" - one = Decimal(1) if currency_from == currency_to: - return one + return Decimal(1) original_date = search_date = get_date(date_str) while original_date - search_date < timedelta(MAX_BACKTRACK_DAYS): date_rates = self.rates.get(search_date.strftime(_DATE), {}) - from_rate = one if currency_from == "EUR" else date_rates.get(currency_from) - to_rate = one if currency_to == "EUR" else date_rates.get(currency_to) + from_rate = "1" if currency_from == "EUR" else date_rates.get(currency_from) + to_rate = "1" if currency_to == "EUR" else date_rates.get(currency_to) if from_rate is not None and to_rate is not None: return Decimal(to_rate) / Decimal(from_rate) search_date -= timedelta(1) diff --git a/ibkr_report/report.py b/ibkr_report/report.py index 4de626bf..4de7a7c5 100644 --- a/ibkr_report/report.py +++ b/ibkr_report/report.py @@ -24,6 +24,18 @@ class Report: """Total selling prices, total capital gains, and total capital losses calculated from the CSV files. + + Args: + file (Iterable[bytes]): The input file in CSV format + report_currency (str): The currency used in the output + use_deemed_acquisition_cost (bool): Whether to use acquisition cost + + Attributes: + prices (Decimal): Total selling prices + gains (Decimal): Total capital gains + losses (Decimal): Total capital losses + details(List): Details from trades such as dates and quantities + options (Dict): Whether to use acquisition cost, report currency """ prices: Decimal = Decimal(0)