Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

💱 Crypto Gain/Loss Converter

Convert Domain Money crypto gain/loss statements into the Koinly universal CSV format — so off-chain broker fills still land in your tax pipeline.

Python Koinly License: GPL v3 Created


The problem

Some brokers settle crypto trades off-chain. That means:

  • There is no clean on-chain trail for Koinly (or similar tools) to auto-import
  • You still get a gain/loss statement with cost basis, proceeds, and dispose dates
  • Manual re-entry is painful and error-prone

Crypto_GainLoss_Converter bridges that gap for Domain Money statements: one CSV in, Koinly-shaped trades out.


What the script does

For every row in the broker export it:

  1. Parses dates — Date Acquired and Date Sold or Disposed (ISO-8601-style timestamps)
  2. Normalizes timezones — treat as UTC, convert to US/Eastern, format for Koinly (YYYY-MM-DD HH:MM TZ)
  3. Splits each lot into two trades
    • Buy on the acquire date (amount = quantity, total = cost basis USD)
    • Sell on the dispose date (amount = quantity, total = proceeds USD)
  4. Builds a Koinly-style frame with pair, side, amount, total, fee columns, and optional IDs
  5. Writes a new CSV ready for import
Domain Money gain/loss CSV
        │
        ▼
  Parse acquire / dispose timestamps
        │
        ▼
  Localize UTC → US/Eastern
        │
        ▼
  Emit Buy row + Sell row per original lot
        │
        ▼
  Koinly universal-format CSV

Output columns

Column Source / value
Koinly Date Acquire or dispose time in US/Eastern
Pair {Property Symbol}-USD
Side Buy or Sell
Amount Property Quantity
Total Cost basis (buy) or proceeds (sell) in USD
Fee Amount 0 (default assumption)
Fee Currency USD
Order ID empty (optional)
Trade ID empty (optional)

Assumptions (important)

These match the original use case and must be true (or the script should be edited):

Assumption Why it matters
All notionals are USD Totals and fee currency are hard-coded as USD
No explicit fees tracked Fee amount is set to 0 — spreads may be invisible
Domain Money column names match the script Renamed exports will break parsing
Timestamps can be parsed after trimming a fixed suffix Format is tied to the original statement layout

If your broker charges fees, uses other quote currencies, or changed their CSV schema, update the mapping before relying on the file for taxes.


Project layout

Crypto_GainLoss_Converter/
├── dm_statement_convert.py   # Domain Money → Koinly converter
├── LICENSE
└── README.md

Setup

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install pandas pytz

Usage

  1. Export your Domain Money gain/loss statement as CSV.
  2. Open dm_statement_convert.py and set the input/output paths:
df = pd.read_csv("/path/to/Original.csv")
# ...
converted_df.to_csv("/path/to/Revised.csv", index=False)
  1. Run:
python dm_statement_convert.py
  1. Import Revised.csv into Koinly using the universal / custom CSV import flow, and spot-check a few lots against the broker PDF/CSV.

Expected input columns

The script expects (at least):

  • Date Acquired
  • Date Sold or Disposed
  • Property Symbol
  • Property Quantity
  • Cost Basis (USD)
  • Proceeds (USD)

Limitations & improvements

  • Uses older DataFrame.append patterns — fine for small statements; for large files prefer pd.concat
  • Paths are absolute placeholders (/Users/johndoe/...) — change them before running
  • No CLI flags yet — a nice upgrade is argparse for --input / --output
  • Fee and multi-currency support would make this more general

Disclaimer

This is a personal data-munging utility, not tax advice. Always verify converted trades against broker statements and consult a qualified tax professional for filing decisions.


License

Distributed under the terms of the GNU General Public License v3.0. See LICENSE for details.


Off-chain broker fills → Koinly-ready CSVs. Built March 2023 with a little help from ChatGPT.

About

Translates transactions from a Domain Money (crypto exchange) Gain/Loss statement from to Koinly universal format.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages