Tax Lot Tracker
A Python CLI tool for cryptocurrency tax lot tracking with FIFO/LIFO/HIFO cost basis methods, exchange API imports, and US tax report generation.
Features
- Cost Basis Methods: FIFO (First In, First Out), LIFO (Last In, First Out), HIFO (Highest In, First Out)
- Exchange Imports: Coinbase, Binance, Kraken APIs
- CSV Import: Generic CSV import with flexible column mapping
- Tax Reports: Form 8949 CSV export for US taxes
- Price Lookup: Automatic historical price fetching from CoinGecko
- Portfolio View: Current holdings with cost basis and P&L
Installation
pip install -e .
Quick Start
1. Import Transactions
From CSV:
tax-lot-tracker import csv transactions.csv
From exchanges (after setting API keys):
tax-lot-tracker config set coinbase_api_key YOUR_KEY
tax-lot-tracker config set coinbase_api_secret YOUR_SECRET
tax-lot-tracker import coinbase
2. Calculate Cost Basis
tax-lot-tracker calculate --method fifo
3. View Portfolio
tax-lot-tracker portfolio --prices
4. Generate Tax Report
tax-lot-tracker report 2024
tax-lot-tracker gains 2024
Commands
Import Commands
# Import from CSV
tax-lot-tracker import csv <file> [--fetch-prices]
# Import from exchanges
tax-lot-tracker import coinbase [--since YYYY-MM-DD]
tax-lot-tracker import binance [--since YYYY-MM-DD] [--us]
tax-lot-tracker import kraken [--since YYYY-MM-DD]
Analysis Commands
# Calculate cost basis
tax-lot-tracker calculate [--method fifo|lifo|hifo] [--recalculate]
# View portfolio
tax-lot-tracker portfolio [--prices]
# View gains/losses
tax-lot-tracker gains <year>
# List transactions
tax-lot-tracker transactions [--asset BTC] [--type buy] [--limit 20]
Report Commands
# Generate Form 8949 CSV
tax-lot-tracker report <year> [-o output.csv]
Configuration
# Set API keys
tax-lot-tracker config set <key> <value>
# Show configuration
tax-lot-tracker config show
# Get a specific value
tax-lot-tracker config get <key>
CSV Format
The CSV importer accepts files with these columns (names are flexible):
| Required | Column Names |
|---|---|
| Yes | timestamp, date, time, datetime |
| Yes | type, transaction type, side, action |
| Yes | asset, symbol, currency, coin |
| Yes | amount, quantity, qty, size |
| One of | price, price_usd OR total, total_usd |
| No | fee, fee_usd, commission |
Example:
timestamp,type,asset,amount,price,fee
2024-01-15 10:30:00,buy,BTC,0.5,42000,10.50
2024-01-20 14:00:00,sell,BTC,0.25,45000,5.25
Transaction types recognized:
- Buy:
buy,purchase,bought - Sell:
sell,sold,sale - Income:
income,reward,staking,mining,interest - Transfer:
transfer,send,receive,deposit,withdrawal
Cost Basis Methods
FIFO (First In, First Out)
Sells the oldest lots first. Often results in larger gains in bull markets.
LIFO (Last In, First Out)
Sells the newest lots first. Can minimize gains if recent purchases were at higher prices.
HIFO (Highest In, First Out)
Sells lots with the highest cost basis first. Minimizes taxable gains.
US Tax Rules
This tool handles:
- Short vs Long-term: Disposals held < 1 year = short-term (higher tax rate)
- Crypto-to-crypto trades: Treated as taxable events
- Fees: Added to cost basis (buys) or reduce proceeds (sells)
- Income: Mining/staking rewards = income at FMV, becomes cost basis
Not currently handled:
- Wash sale rule (IRS guidance unclear for crypto)
- Specific identification (manually picking lots)
Database
All data is stored in tax_lots.db (SQLite) in the current directory. Tables:
transactions: Raw imported transactionslots: Tax lots (created from buys/income)disposals: Matched disposals (created from sells)config: API keys and settingsprice_cache: Cached historical prices
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=tax_lot_tracker
License
MIT
Metadata
Release files for tax-lot-tracker 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tax_lot_tracker-0.1.0.tar.gz | 39.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tax_lot_tracker-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.2 kB
Release files / tax_lot_tracker-0.1.0.tar.gz
| Download URL | tax_lot_tracker-0.1.0.tar.gz |
|---|---|
| Size | 39.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0354d68af8afa6e3797e1064bec22c81de65d63c8f720864f32e5b0dd31194ce
|
|
BLAKE2b-256 checksum How to use checksums |
2dc9ba6dbf7ce75cb704be9abee161664f43e81db83836364b0021bdff51114a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / tax_lot_tracker-0.1.0-py3-none-any.whl
| Download URL | tax_lot_tracker-0.1.0-py3-none-any.whl |
|---|---|
| Size | 45.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4aec2951640a0955a160937f24144cc4a86c573230d7a36ca235854137e476c0
|
|
BLAKE2b-256 checksum How to use checksums |
252dcf99684d318a18c90b55210abc604c9b334c00e0bba275eadfa783681c09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|