diff options
author | uvok | 2025-04-15 12:19:30 +0200 |
---|---|---|
committer | uvok | 2025-04-15 12:19:30 +0200 |
commit | 4543d2a64c50e9234b969b9fa0bff3d5b7bf665d (patch) | |
tree | fa07e90b11c7ad7fe075c3434f4644d7b7ed05a9 | |
parent | 0cb91ee94493a08ba234d9dd7057a1768900f3cb (diff) |
Upgrade main program to use Decimal
-rw-r--r-- | bla.py | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -2,6 +2,7 @@ import csv from collections import defaultdict from datetime import datetime from decimal import Decimal +import logging from typing import Dict, List from trade import Trade @@ -52,7 +53,7 @@ def process_ledger(file_path, output_path): elif row["type"] == "deposit" and row["asset"] != "EUR": currency = row["asset"] fifo_queues.setdefault(currency, FIFOQueue()) - amount = float(row["amount"]) + amount = Decimal(row["amount"]) price = 0 # Deposits typically have no associated cost basis date = row["time"].split(" ")[0] fifo_queues[currency].add(amount, price, date) @@ -65,10 +66,10 @@ def process_ledger(file_path, output_path): if eur_trade and crypto_trade: crypto_asset = crypto_trade["asset"] - eur_amount = float(eur_trade["amount"]) - eur_fee = float(eur_trade["fee"]) - crypto_amount = float(crypto_trade["amount"]) - crypto_fee = float(crypto_trade["fee"]) + eur_amount = Decimal(eur_trade["amount"]) + eur_fee = Decimal(eur_trade["fee"]) + crypto_amount = Decimal(crypto_trade["amount"]) + crypto_fee = Decimal(crypto_trade["fee"]) fifo_queues.setdefault(crypto_asset, FIFOQueue()) date_sold = eur_trade["time"].split(" ")[0] @@ -104,6 +105,8 @@ def process_ledger(file_path, output_path): writer.writeheader() writer.writerows(report) +logging.basicConfig(level=logging.DEBUG) + # Usage ledger_path = "kraken_ledger.csv" # Replace with your ledger file path output_path = "tax_report.csv" # Replace with your desired output file path |