summaryrefslogtreecommitdiff
path: root/bla.py
diff options
context:
space:
mode:
authoruvok2025-04-13 15:34:59 +0200
committeruvok2025-04-13 15:34:59 +0200
commit1f4ddbde87c22e5bbb295d0a0ecffda3e9699313 (patch)
tree3eef124f07e4dbaa8775855646364f5301a427c9 /bla.py
parent67d6e4dc70c4ab5d9cc90ee73fae9d42db15e0ca (diff)
Handle deposits
Diffstat (limited to 'bla.py')
-rw-r--r--bla.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/bla.py b/bla.py
index d6fbecc..3d1cfb7 100644
--- a/bla.py
+++ b/bla.py
@@ -35,17 +35,24 @@ def process_ledger(file_path):
reader = csv.DictReader(file)
for row in reader:
currency = row["asset"]
- # Use setdefault() for streamlined dictionary handling
fifo_queues.setdefault(currency, FIFOQueue())
- if row["type"] == "trade" and row["amount"].startswith('-'): # Sale
+ # Handle deposits
+ if row["type"] == "deposit":
+ amount = float(row["amount"])
+ price = 0 # Deposits typically have no associated cost basis
+ fifo_queues[currency].add(amount, price)
+
+ # Handle trades - sales
+ elif row["type"] == "trade" and row["amount"].startswith('-'):
amount = -float(row["amount"])
cost_basis = fifo_queues[currency].remove(amount)
sale_proceeds = amount * float(row["fee"]) # Adjust fee as needed
profit_or_loss = sale_proceeds - cost_basis
report.append((row["time"], currency, profit_or_loss))
- elif row["type"] == "trade" and not row["amount"].startswith('-'): # Purchase
+ # Handle trades - purchases
+ elif row["type"] == "trade" and not row["amount"].startswith('-'):
amount = float(row["amount"])
price = float(row["fee"]) # Adjust fee as needed
fifo_queues[currency].add(amount, price)