backtrader
Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers,…
Export trade history and tax calculations in formats compatible with Koinly, CoinTracker, CoinLedger, TokenTax, and IRS Form 8949
$ npx -y skills add agiprolabs/claude-trading-skills --skill crypto-tax-export --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/crypto-tax-exportContext preview
The summary Claude sees to decide when to auto-load this skill.
Export trade history and tax calculations in formats compatible with Koinly, CoinTracker, CoinLedger, TokenTax, and IRS Form 8949
name: crypto-tax-export description: Export trade history and tax calculations in formats compatible with Koinly, CoinTracker, CoinLedger, TokenTax, and IRS Form 8949 license: MIT metadata: author: agipro version: "0.1.0" category: trading
Export trade history and tax calculations for tax software and IRS filing. Handles Solana-specific transaction types (Jupiter swaps, LP operations, staking rewards, airdrops) and generates CSVs compatible with Koinly, CoinTracker, CoinLedger, TokenTax, TurboTax/TaxAct, and IRS Form 8949.
> **Disclaimer:** This skill provides data formatting and calculation tools only. It does not constitute tax advice. Consult a qualified tax professional for guidance on reporting cryptocurrency transactions. Tax laws vary by jurisdiction and change frequently.
| Capability | Description | |---|---| | Multi-format CSV export | Koinly, CoinTracker, CoinLedger, TokenTax, TurboTax, TaxAct | | IRS Form 8949 generation | Part I (short-term) and Part II (long-term), columns a through h | | Solana tx classification | Jupiter swaps, multi-hop routes, LP deposits/withdrawals, staking, airdrops | | Cost basis methods | FIFO, LIFO, HIFO, Specific Identification | | Reconciliation | Match on-chain history against internal trade journal | | Failed tx handling | Identify and exclude failed transactions (no taxable event) |
Koinly expects a universal import format with these columns:
Date,Sent Amount,Sent Currency,Received Amount,Received Currency,Fee Amount,Fee Currency,Net Worth Amount,Net Worth Currency,Label,Description,TxHash
Labels: `swap`, `staking`, `airdrop`, `liquidity_in`, `liquidity_out`, `cost`, `gift`, `lost`.
Date,Received Quantity,Received Currency,Sent Quantity,Sent Currency,Fee Amount,Fee Currency,Tag
Tags: `trade`, `staking_reward`, `airdrop`, `lp_deposit`, `lp_withdrawal`.
Date (UTC),Type,Received Currency,Received Amount,Sent Currency,Sent Amount,Fee Currency,Fee Amount,Exchange/Wallet
Types: `Trade`, `Income`, `Gift Received`, `Mining`, `Staking Reward`, `Airdrop`.
Type,BuyAmount,BuyCurrency,SellAmount,SellCurrency,FeeAmount,FeeCurrency,Exchange,Group,Comment,Date
Types: `Trade`, `Income`, `Staking`, `Airdrop`, `Spending`.
Both accept a simplified Form 8949 format:
Description of Property,Date Acquired,Date Sold,Proceeds,Cost Basis,Gain or Loss
Part I — Short-term (held one year or less). Part II — Long-term (held more than one year).
Columns:
Check box: **(A)** if basis reported to IRS, **(B)** if not, **(C)** if Form 1099-B not received.
A direct token-to-token swap. Classified as a **disposal** of the sent token and **acquisition** of the received token. Each side is a taxable event.
tx = {
"type": "swap",
"sent": {"amount": 1.5, "currency": "SOL", "usd_value": 225.00},
"received": {"amount": 50000, "currency": "BONK", "usd_value": 224.50},
"fee": {"amount": 0.000005, "currency": "SOL", "usd_value": 0.00075},
"timestamp": "2025-03-15T14:30:00Z",
"tx_hash": "5abc...def",
}A routed swap through intermediate tokens (e.g., SOL -> USDC -> BONK). Only the **initial send** and **final receive** matter for tax purposes. Intermediate hops are not separate taxable events.
Staking rewards (SOL validator rewards, liquid staking yield) are **income** at fair market value when received. Cost basis equals the FMV at receipt.
Airdrops are **income** at fair market value when the recipient gains dominion and control. Some jurisdictions differ on when dominion is established.
A 1:1 token migration (e.g., protocol upgrade) is generally **not** a taxable event. The new token inherits the cost basis and holding period of the old token.
Failed Solana transactions (status: failed, or inner instruction errors) are **not** taxable events. The transaction fee (SOL) may still be deductible as a cost of doing business in some jurisdictions. Always exclude failed txs from trade export.
from enum import Enum
class CostBasisMethod(Enum):
FIFO = "fifo" # First In, First Out (IRS default)
LIFO = "lifo" # Last In, First Out
HIFO = "hifo" # Highest In, First Out (minimizes gains)
SPEC_ID = "spec_id" # Specific Identification (requires lot tracking)
def compute_gain(
proceeds: float,
cost_basis: float,
adjustments: float = 0.0,
) -> float:
"""Compute gain or loss for Form 8949 column (h)."""
return proceeds - cost_basis + adjustmentsReconciling on-chain history with an internal trade journal catches:
1. **Missing trades** — on-chain tx not in journal (manual entry missed) 2. **Pha
A comprehensive collection of 68 ready-to-use trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools.
Repo: agiprolabs/claude-trading-skills
Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers,…
Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security…
Broad crypto market data from CoinGecko covering 13,000+ tokens. Global market stats,…
Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability…
Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading
Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail…