$npx -y skills add agiprolabs/claude-trading-skills --skill tax-loss-harvestingTax-loss harvesting opportunity identification, scoring, and planning with wash sale compliance and annual carryforward tracking
| 1 | # Tax-Loss Harvesting |
| 2 | |
| 3 | Identify, score, and plan tax-loss harvesting (TLH) opportunities across a crypto portfolio. This skill covers unrealized-loss ranking, net-benefit calculation, wash sale compliance, annual loss carryforward tracking, and year-end "use it or lose it" strategies. |
| 4 | |
| 5 | > **Disclaimer:** This skill provides informational analysis only. It is NOT tax advice. Tax rules vary by jurisdiction and change frequently. Consult a qualified tax professional before making any tax-related trading decisions. |
| 6 | |
| 7 | ## How Tax-Loss Harvesting Works |
| 8 | |
| 9 | Tax-loss harvesting is the practice of intentionally realizing investment losses to offset realized capital gains, thereby reducing your current-year tax liability. |
| 10 | |
| 11 | ### Core Mechanism |
| 12 | |
| 13 | 1. **Identify** positions with unrealized losses in your portfolio. |
| 14 | 2. **Sell** those positions to realize the loss. |
| 15 | 3. **Offset** realized gains with the harvested loss, reducing taxable income. |
| 16 | 4. **Optionally re-enter** a similar (but not "substantially identical") position to maintain market exposure. |
| 17 | |
| 18 | ### Short-Term vs Long-Term |
| 19 | |
| 20 | | Holding Period | Classification | Typical Tax Rate | |
| 21 | |---------------|---------------|-----------------| |
| 22 | | < 1 year | Short-term capital gain/loss | Ordinary income rate | |
| 23 | | >= 1 year | Long-term capital gain/loss | Preferential rate (0-20%) | |
| 24 | |
| 25 | Short-term losses first offset short-term gains; long-term losses first offset long-term gains. Remaining net losses cross over to offset the other category. |
| 26 | |
| 27 | ### Annual Loss Deduction Limit |
| 28 | |
| 29 | If total net losses exceed total gains, the excess is deductible against ordinary income up to **$3,000 per year** ($1,500 if married filing separately). Any remaining loss carries forward indefinitely to future tax years. |
| 30 | |
| 31 | ## Ranking Unrealized Losses |
| 32 | |
| 33 | Not all unrealized losses are equally valuable to harvest. This skill scores each opportunity on four dimensions: |
| 34 | |
| 35 | ### 1. Loss Magnitude |
| 36 | |
| 37 | Larger dollar losses provide more tax savings. The raw loss is the difference between current market value and cost basis. |
| 38 | |
| 39 | ``` |
| 40 | unrealized_loss = current_value - cost_basis # negative when loss |
| 41 | tax_savings = abs(unrealized_loss) * marginal_tax_rate |
| 42 | ``` |
| 43 | |
| 44 | ### 2. Days Until Long-Term Threshold |
| 45 | |
| 46 | A position approaching the 1-year holding mark deserves special consideration: |
| 47 | - If close to crossing into long-term territory, harvesting now locks in a **short-term loss** (offsets higher-taxed short-term gains). |
| 48 | - If already long-term, the loss offsets long-term gains (lower tax rate benefit). |
| 49 | |
| 50 | ``` |
| 51 | days_held = (today - acquisition_date).days |
| 52 | days_to_long_term = max(0, 365 - days_held) |
| 53 | ``` |
| 54 | |
| 55 | Positions with fewer days remaining until long-term are **more urgent** to evaluate because once they cross 365 days, a short-term loss becomes a less-valuable long-term loss. |
| 56 | |
| 57 | ### 3. Wash Sale Risk (Correlation Score) |
| 58 | |
| 59 | The IRS wash sale rule prohibits claiming a loss if you buy a "substantially identical" security within 30 days before or after the sale. In crypto, the exact application is evolving, but prudent planning avoids re-entering the same token within the 61-day wash sale window (30 days before + sale day + 30 days after). |
| 60 | |
| 61 | **Correlation scoring**: If you hold (or plan to re-enter) a position that is highly correlated with the harvested asset, wash sale risk increases. Score this as: |
| 62 | |
| 63 | ``` |
| 64 | wash_sale_risk = 1.0 # if same token re-entry planned within 30 days |
| 65 | wash_sale_risk = correlation_coefficient # if correlated substitute held |
| 66 | wash_sale_risk = 0.0 # if no re-entry or uncorrelated substitute |
| 67 | ``` |
| 68 | |
| 69 | Higher wash sale risk reduces the effective score of the opportunity. |
| 70 | |
| 71 | ### 4. Available Gains to Offset |
| 72 | |
| 73 | A harvested loss is only immediately useful if there are realized gains to offset. Score opportunities higher when: |
| 74 | - There are matching-type gains (short-term loss vs short-term gain). |
| 75 | - The loss amount does not greatly exceed available gains (diminishing marginal benefit beyond the $3K deduction cap). |
| 76 | |
| 77 | ``` |
| 78 | offset_efficiency = min(1.0, available_matching_gains / abs(unrealized_loss)) |
| 79 | ``` |
| 80 | |
| 81 | ### Composite Score |
| 82 | |
| 83 | ```python |
| 84 | def tlh_score( |
| 85 | unrealized_loss: float, |
| 86 | days_to_long_term: int, |
| 87 | wash_sale_risk: float, |
| 88 | offset_efficiency: float, |
| 89 | weights: dict | None = None, |
| 90 | ) -> float: |
| 91 | w = weights or { |
| 92 | "magnitude": 0.35, |
| 93 | "urgency": 0.25, |
| 94 | "wash_safety": 0.20, |
| 95 | "offset_match": 0.20, |
| 96 | } |
| 97 | magnitude_score = min(abs(unrealized_loss) / 10_000, 1.0) |
| 98 | urgency_score = max(0, 1.0 - days_to_long_term / 365) |
| 99 | wash_safety_score = 1.0 - wash_sale_risk |
| 100 | return ( |
| 101 | w["magnitude"] * magnitude_score |
| 102 | + w["urgency"] * urgency_score |
| 103 | + w["wash_safety"] * wash_safety_score |
| 104 | + w["offset_match"] * offset_efficiency |
| 105 | ) |
| 106 | ``` |
| 107 | |
| 108 | ## Net Benefit Calcula |