Skip to content

Commit

Permalink
cointracker: added realized pnl support (margin gain/margin loss)
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgerpodger committed Feb 26, 2025
1 parent 81d0587 commit 55e500c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/staketaxcsv/common/Exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _rows_export(self, csv_format, reverse=True, export_all=False):
allowed_types = list(et.TX_TYPES_CSVEXPORT)

# List of csv formats that support REALIZED_PNL
if csv_format in [et.FORMAT_KOINLY, et.FORMAT_COINTRACKING]:
if csv_format in [et.FORMAT_KOINLY, et.FORMAT_COINTRACKING, et.FORMAT_COINTRACKER]:
allowed_types.append(et.TX_TYPE_REALIZED_PNL)

# Filter rows based on the allowed tx types.
Expand Down Expand Up @@ -615,7 +615,14 @@ def export_cointracker_csv(self, csvpath):

# data rows
for row in rows:
tag = tags[row.tx_type]

if row.tx_type == et.TX_TYPE_REALIZED_PNL:
if row.received_amount and float(row.received_amount) > 0:
tag = "margin gain"
elif row.sent_amount and float(row.sent_amount) > 0:
tag = "margin loss"
else:
tag = tags[row.tx_type]

line = [
self._cointracker_timestamp(row.timestamp), # Date
Expand Down

0 comments on commit 55e500c

Please sign in to comment.