@@ -61,17 +61,15 @@ Everything is scriptable and automation-friendly.
6161
6262## Installation
6363
64- ``` bash
64+
6565pip install -r requirements.txt
6666For development / tests:
6767
68- bash
69- Copy code
68+
7069pip install -r requirements-dev.txt
7170Configuration
7271API Keys (Environment Variables)
73- bash
74- Copy code
72+
7573export COINBASE_API_KEY="..."
7674export COINBASE_SECRET="..."
7775
@@ -82,48 +80,42 @@ export BINANCEUS_API_KEY="..."
8280export BINANCEUS_SECRET="..."
8381Optional config.yaml
8482yaml
85- Copy code
83+
8684exchanges:
8785 - coinbase
8886 - kraken
89- # - binanceus
87+ - binanceus
88+
9089Basic Usage
90+
9191Sync all configured exchanges
92- bash
93- Copy code
92+
9493python3 crypto_pnl_tool.py
9594Sync only (no calculations)
96- bash
97- Copy code
95+
9896python3 crypto_pnl_tool.py --sync-only
9997Skip syncing (use local DB only)
100- bash
101- Copy code
98+
10299python3 crypto_pnl_tool.py --no-sync
103100Inspection & Audit Commands
104101List deposits (for cost basis overrides)
105- bash
106- Copy code
102+
107103python3 crypto_pnl_tool.py --list-deposits --no-sync
108104List withdrawals
109- bash
110- Copy code
105+
111106python3 crypto_pnl_tool.py --list-withdrawals --no-sync
112107List recent trades
113- bash
114- Copy code
108+
115109python3 crypto_pnl_tool.py --list-trades --trade-limit 50 --no-sync
116110Inspect open FIFO lots (audit view)
117- bash
118- Copy code
111+
119112# Single pair
120113python3 crypto_pnl_tool.py --open-lots BTC/USD --no-sync
121114
122115# All quote pairs for a base asset
123116python3 crypto_pnl_tool.py --open-lots BTC --no-sync
124117Cost Basis Overrides (External Wallets)
125- python
126- Copy code
118+
127119from decimal import Decimal
128120from crypto_pnl_tool import get_db_conn, add_cost_basis_override
129121
@@ -139,88 +131,60 @@ add_cost_basis_override(
139131Overrides create synthetic FIFO lots used in realized P&L.
140132
141133P&L Output
142- bash
143- Copy code
144134python3 crypto_pnl_tool.py
145135Example:
146-
147- makefile
148- Copy code
149136BTC/USD: P&L=-8.74 USD, Fees=1.23 USD
150137ETH/USD: P&L=412.55 USD, Fees=4.10 USD
151- Portfolio totals:
152138
153- bash
154- Copy code
139+ Portfolio totals:
155140python3 crypto_pnl_tool.py --portfolio
1561418949-Style Tax Export
142+
157143Detailed FIFO export
158- bash
159- Copy code
160144python3 crypto_pnl_tool.py \
161145 --tax-year 2025 \
162146 --export-8949 8949_2025.csv
163147Optional rounding (export only)
164- bash
165- Copy code
148+
166149python3 crypto_pnl_tool.py \
167150 --tax-year 2025 \
168151 --export-8949 8949_2025.csv \
169152 --currency-decimals 2 \
170153 --asset-decimals 8
154+
171155Summary totals (separate file)
172- bash
173- Copy code
174156python3 crypto_pnl_tool.py \
175157 --tax-year 2025 \
176158 --export-8949-summary 8949_summary_2025.csv
177159Data Storage
178160All data is stored locally in:
179-
180- Copy code
181161crypto_pnl.sqlite
182- Benefits:
183162
163+ Benefits:
184164Full auditability
185-
186165No repeated historical API calls
187-
188166Easy inspection with SQLite tools
189-
190167Testing
191168Run FIFO unit tests:
192-
193- bash
194- Copy code
195169pytest -q
196- Tests cover:
197170
171+ Tests cover:
198172FIFO math
199-
200173Partial lots
201-
202174Fees
203-
204175Deposit overrides
205-
206176Year filtering
207177
208178Docker (Optional)
209179Docker is provided as a convenience only.
210-
211- bash
212- Copy code
213180docker build -t crypto-pnl-tool .
214- bash
215- Copy code
216181docker run --rm \
217182 -e COINBASE_API_KEY="..." \
218183 -e COINBASE_SECRET="..." \
219184 -v "$(pwd):/app" \
220185 crypto-pnl-tool
186+
221187Project Structure
222- text
223- Copy code
224188crypto-pnl-tool/
225189├── crypto_pnl_tool.py
226190├── crypto_pnl.sqlite
@@ -240,13 +204,9 @@ This tool is for accounting and analysis — not tax or legal advice.
240204
241205Roadmap (Optional)
242206TurboTax-specific import mapping
243-
244207USD normalization for non-USD quotes
245-
246208FastAPI service wrapper
247-
248209Web dashboard
249-
250210Multi-year carryover validation
251211
252212License
0 commit comments