diff options
-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 |