backtrader
Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers,…
Wash sale detection under 2025 US crypto rules with 61-day window monitoring, disallowed loss tracking, and safe re-entry countdown
$ npx -y skills add agiprolabs/claude-trading-skills --skill wash-sale-detection --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/wash-sale-detectionContext preview
The summary Claude sees to decide when to auto-load this skill.
Wash sale detection under 2025 US crypto rules with 61-day window monitoring, disallowed loss tracking, and safe re-entry countdown
name: wash-sale-detection description: Wash sale detection under 2025 US crypto rules with 61-day window monitoring, disallowed loss tracking, and safe re-entry countdown license: MIT metadata: author: agipro version: "0.1.0" category: trading
Detect wash sales under current US crypto tax rules (effective 2025), monitor the 61-day window around realized losses, track disallowed losses with basis adjustments, and compute safe re-entry countdowns.
> **Disclaimer**: This skill provides informational analysis only. It is NOT tax advice. Consult a qualified tax professional or CPA for guidance on your specific situation. Tax law is complex, and the application of wash sale rules to cryptocurrency may vary based on individual circumstances, IRS guidance updates, and court rulings.
Before 2025, cryptocurrency was not subject to the wash sale rule because digital assets were classified as property rather than securities. The **Infrastructure Investment and Jobs Act** and subsequent IRS rulemaking extended wash sale treatment to digital assets beginning January 1, 2025.
Under **IRC Section 1091** (as amended for digital assets), if you sell or dispose of a cryptocurrency at a loss and acquire a **substantially identical** asset within a **61-day window** (30 days before the sale through 30 days after), the loss is **disallowed** for tax purposes. The disallowed loss is added to the cost basis of the replacement position.
Day -30 ................. Day 0 ................. Day +30 |--- 30 days before ---|--- sale day ---|--- 30 days after ---| ^ ^ ^ Window opens Loss realized Window closes
For crypto, "substantially identical" generally means the **same token**. Selling SOL at a loss and buying SOL within 30 days is a wash sale. Selling SOL and buying ETH is not (they are different assets).
Edge cases that may be scrutinized:
When a wash sale occurs: 1. The realized loss is **disallowed** — you cannot deduct it in the current tax year 2. The disallowed loss is **added to the cost basis** of the replacement position 3. The holding period of the original position may carry over to the replacement
**Example**:
1. **Wash Sale Scanning** — Analyze a trade history and flag all wash sale violations 2. **61-Day Window Monitoring** — Track open windows for recent loss-generating sales 3. **Disallowed Loss Calculation** — Compute the exact disallowed amount per wash sale 4. **Basis Adjustment Tracking** — Show adjusted cost basis for replacement positions 5. **Safe Re-Entry Countdown** — For each token sold at a loss, show days remaining until safe to re-enter 6. **Automation Hazard Detection** — Flag copy-trade systems or bot strategies that may inadvertently trigger wash sales
from datetime import date
# Define your trade history
trades = [
{"date": date(2025, 3, 1), "action": "buy", "token": "SOL", "qty": 10, "price": 100.0},
{"date": date(2025, 3, 15), "action": "sell", "token": "SOL", "qty": 10, "price": 80.0},
{"date": date(2025, 3, 25), "action": "buy", "token": "SOL", "qty": 10, "price": 85.0},
]
# Check for wash sales
from scripts.wash_sale_scanner import WashSaleScanner
scanner = WashSaleScanner(trades)
results = scanner.scan()
for ws in results.wash_sales:
print(f"WASH SALE: {ws.token} — Loss ${ws.disallowed_loss:.2f} disallowed")
print(f" Sale: {ws.sale_date} | Re-entry: {ws.replacement_date}")
print(f" Adjusted basis: ${ws.adjusted_basis:.2f}")
# Check safe re-entry countdowns
for countdown in results.countdowns:
print(f"{countdown.token}: {countdown.days_remaining} days until safe re-entry")Scan your full year of trading activity to identify all wash sales before filing taxes. Generate a report showing total disallowed losses and adjusted cost bases.
Before placing a buy order, check whether the token has an open wash sale window from a recent loss. Avoid inadvertent wash sales by waiting for the countdown to expire.
Automated trading systems (copy-trading bots, DCA bots, grid bots) frequently trigger wash sales because they buy and sell the same tokens repeatedly. Run this scanner on bot trade exports to quantify the tax impact.
When executing a tax-loss harvesting strategy, use the safe re-entry countdown to plan when you can re-enter positions. Swap into a non-identical asset during the 30-day window if you want to maintain market exposure.
The wash sale rule applies across all accounts controlled by the same taxpayer. If you trade SOL on multiple exchanges or wallet
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…