Tax Loss Harvestingのロゴ

Tax Loss Harvesting

コミュニティ
agiprolabs
tax-loss-harvesting

ウォッシュセール規則への準拠と年間繰越額の追跡を含む、税務上の損失確定機会の特定、評価、計画

Add to TypingMind

概要

公開者agiprolabs
リポジトリclaude-trading-skills
スキル名tax-loss-harvesting
スター
434
フォーク
85
同梱ファイル
2
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    agiprolabsがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Tax Loss Harvesting」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/agiprolabs/claude-trading-skills/tree/main/skills/tax-loss-harvesting
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/agiprolabs/claude-trading-skills.git /tmp/claude-trading-skills
mkdir -p .claude/skills
cp -r /tmp/claude-trading-skills/skills/tax-loss-harvesting .claude/skills/tax-loss-harvesting
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでTax Loss Harvestingを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にTax Loss Harvestingを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Tax Loss Harvestingは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Tax-Loss Harvesting

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.

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.

How Tax-Loss Harvesting Works

Tax-loss harvesting is the practice of intentionally realizing investment losses to offset realized capital gains, thereby reducing your current-year tax liability.

Core Mechanism

  1. Identify positions with unrealized losses in your portfolio.
  2. Sell those positions to realize the loss.
  3. Offset realized gains with the harvested loss, reducing taxable income.
  4. Optionally re-enter a similar (but not "substantially identical") position to maintain market exposure.

Short-Term vs Long-Term

Holding PeriodClassificationTypical Tax Rate
< 1 yearShort-term capital gain/lossOrdinary income rate
>= 1 yearLong-term capital gain/lossPreferential rate (0-20%)

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.

Annual Loss Deduction Limit

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.

Ranking Unrealized Losses

Not all unrealized losses are equally valuable to harvest. This skill scores each opportunity on four dimensions:

1. Loss Magnitude

Larger dollar losses provide more tax savings. The raw loss is the difference between current market value and cost basis.

unrealized_loss = current_value - cost_basis  # negative when loss
tax_savings = abs(unrealized_loss) * marginal_tax_rate

2. Days Until Long-Term Threshold

A position approaching the 1-year holding mark deserves special consideration:

  • If close to crossing into long-term territory, harvesting now locks in a short-term loss (offsets higher-taxed short-term gains).
  • If already long-term, the loss offsets long-term gains (lower tax rate benefit).
days_held = (today - acquisition_date).days
days_to_long_term = max(0, 365 - days_held)

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.

3. Wash Sale Risk (Correlation Score)

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).

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:

wash_sale_risk = 1.0  # if same token re-entry planned within 30 days
wash_sale_risk = correlation_coefficient  # if correlated substitute held
wash_sale_risk = 0.0  # if no re-entry or uncorrelated substitute

Higher wash sale risk reduces the effective score of the opportunity.

4. Available Gains to Offset

A harvested loss is only immediately useful if there are realized gains to offset. Score opportunities higher when:

  • There are matching-type gains (short-term loss vs short-term gain).
  • The loss amount does not greatly exceed available gains (diminishing marginal benefit beyond the $3K deduction cap).
offset_efficiency = min(1.0, available_matching_gains / abs(unrealized_loss))

Composite Score

python
def tlh_score(
    unrealized_loss: float,
    days_to_long_term: int,
    wash_sale_risk: float,
    offset_efficiency: float,
    weights: dict | None = None,
) -> float:
    w = weights or {
        "magnitude": 0.35,
        "urgency": 0.25,
        "wash_safety": 0.20,
        "offset_match": 0.20,
    }
    magnitude_score = min(abs(unrealized_loss) / 10_000, 1.0)
    urgency_score = max(0, 1.0 - days_to_long_term / 365)
    wash_safety_score = 1.0 - wash_sale_risk
    return (
        w["magnitude"] * magnitude_score
        + w["urgency"] * urgency_score
        + w["wash_safety"] * wash_safety_score
        + w["offset_match"] * offset_efficiency
    )

Net Benefit Calculation

Harvesting a loss is not free. Transaction costs (swap fees, slippage, gas) reduce the benefit.

python
def net_benefit(
    unrealized_loss: float,
    marginal_tax_rate: float,
    transaction_cost: float,
    re_entry_cost: float = 0.0,
) -> float:
    """Compute net dollar benefit of harvesting a loss.

    Args:
        unrealized_loss: Negative number representing the loss.
        marginal_tax_rate: Applicable tax rate (0.0 to 1.0).
        transaction_cost: Cost to execute the sell (fees + slippage).
        re_entry_cost: Cost to re-enter a substitute position.

    Returns:
        Net benefit in dollars. Positive means harvesting is worthwhile.
    """
    tax_savings = abs(unrealized_loss) * marginal_tax_rate
    total_costs = transaction_cost + re_entry_cost
    return tax_savings - total_costs

Rule of thumb: Only harvest when net_benefit > 0 by a meaningful margin. Very small losses are not worth the transaction costs and operational complexity.

Year-End "Use It or Lose It"

Near December 31, evaluate whether to accelerate harvesting:

  1. Tally year-to-date realized gains (both short-term and long-term).
  2. Identify unrealized losses that can offset those gains.
  3. Prioritize losses that offset same-type gains (short-term loss vs short-term gain yields the highest tax rate differential).
  4. Check the $3K excess limit: If net losses already exceed gains by $3K, additional harvesting this year has no immediate tax benefit (though the carryforward still has value).
  5. Consider settlement timing: Ensure trades settle before year-end.

Wash Sale Compliance

The 61-Day Window

The wash sale rule applies to purchases of substantially identical securities within:

  • 30 days before the sale (retroactive wash sale)
  • The day of the sale
  • 30 days after the sale

If triggered, the disallowed loss is added to the cost basis of the replacement shares, deferring (not eliminating) the tax benefit.

Compliance Strategies

StrategyDescriptionTrade-off
Wait 31 daysSell, wait 31 days, re-buyMarket exposure gap
Substitute assetSell, immediately buy a non-identical but correlated assetTracking error
No re-entrySell and stay outLost upside
Double-upBuy additional shares, wait 31 days, sell original lotCapital intensive

Crypto-Specific Considerations

  • The IRS has not explicitly ruled that the wash sale rule applies to cryptocurrency (as of 2025). However, proposed legislation may extend it.
  • Prudent practitioners treat crypto as subject to wash sale rules for conservative planning.
  • Different tokens (e.g., SOL vs ETH) are generally considered non-identical.
  • Wrapped versions of the same token (e.g., SOL vs wSOL) may be considered substantially identical.

Annual Loss Carryforward Tracking

python
def compute_carryforward(
    realized_gains_st: float,
    realized_gains_lt: float,
    realized_losses_st: float,
    realized_losses_lt: float,
    prior_carryforward: float = 0.0,
    annual_deduction_limit: float = 3_000.0,
) -> dict:
    """Compute net tax position and carryforward.

    Returns dict with keys:
        net_st, net_lt, total_net,
        deduction_used, carryforward
    """
    net_st = realized_gains_st + realized_losses_st  # losses are negative
    net_lt = realized_gains_lt + realized_losses_lt
    total_net = net_st + net_lt - prior_carryforward

    if total_net >= 0:
        return {
            "net_st": net_st, "net_lt": net_lt,
            "total_net": total_net, "deduction_used": 0.0,
            "carryforward": 0.0,
        }

    excess_loss = abs(total_net)
    deduction_used = min(excess_loss, annual_deduction_limit)
    carryforward = max(0, excess_loss - annual_deduction_limit)
    return {
        "net_st": net_st, "net_lt": net_lt,
        "total_net": total_net,
        "deduction_used": deduction_used,
        "carryforward": carryforward,
    }

Prerequisites

  • Python 3.10+
  • No external dependencies for core calculations
  • Portfolio data: cost basis, acquisition date, current market value per lot
  • Tax parameters: marginal tax rate, filing status, prior carryforward

Capabilities

CapabilityDescription
Opportunity scanningIdentify all positions with unrealized losses
Multi-factor scoringRank by magnitude, urgency, wash safety, offset match
Net benefit analysisCompare tax savings against transaction costs
Wash sale trackingFlag positions within the 61-day window
Carryforward calculatorTrack annual $3K limit and loss carryforward
Year-end planningPrioritize harvesting before December 31
Harvesting plan outputGenerate actionable plan with sell orders and re-entry dates

Quick Start

python
from datetime import date

# Define a portfolio position
position = {
    "symbol": "TOKEN-A",
    "cost_basis": 10_000.0,
    "current_value": 6_500.0,
    "acquisition_date": date(2025, 8, 15),
    "quantity": 500.0,
}

unrealized_loss = position["current_value"] - position["cost_basis"]  # -3500
days_held = (date.today() - position["acquisition_date"]).days
days_to_lt = max(0, 365 - days_held)

# Score the opportunity
score = tlh_score(
    unrealized_loss=unrealized_loss,
    days_to_long_term=days_to_lt,
    wash_sale_risk=0.0,
    offset_efficiency=0.8,
)
print(f"TLH score: {score:.3f}")

# Calculate net benefit
benefit = net_benefit(
    unrealized_loss=unrealized_loss,
    marginal_tax_rate=0.35,
    transaction_cost=15.0,
    re_entry_cost=15.0,
)
print(f"Net benefit: ${benefit:.2f}")

Use Cases

  1. Quarterly portfolio review: Scan all positions for harvesting opportunities ranked by composite score.
  2. Year-end tax planning: Identify optimal set of positions to harvest before December 31 given year-to-date gain/loss totals.
  3. Ongoing monitoring: Flag positions that are approaching the long-term threshold where harvesting a short-term loss becomes urgent.
  4. Carryforward management: Track multi-year loss carryforward balances and project when they will be fully utilized.
  5. Transaction cost analysis: Determine minimum loss threshold worth harvesting given current fee environment.

Files

FileDescription
references/planned_features.mdTLH mechanics, scoring formula, wash sale interaction, carryforward rules, year-end strategies
scripts/harvest_scanner.pyDemo scanner: score opportunities, generate harvesting plan, compute net benefit

Important: This skill provides analytical tools for informational purposes only. All tax-related decisions should be reviewed by a qualified tax professional. Tax laws vary by jurisdiction and are subject to change.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Tax Loss Harvesting」では何ができますか?

ウォッシュセール規則への準拠と年間繰越額の追跡を含む、税務上の損失確定機会の特定、評価、計画

TypingMindでTax Loss Harvestingを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Tax Loss Harvestingはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにTax Loss Harvestingをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/agiprolabs/claude-trading-skills/tree/main/skills/tax-loss-harvestingを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Tax Loss Harvestingを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Tax Loss Harvestingで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもTax Loss Harvestingを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Tax Loss Harvesting」は無料ですか?

はい。agiprolabsがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇