mcpField
T
trade-journal

trade-journal

github.com/agiprolabsデータ・データベース456524 回インストール8 週間前に更新
リポジトリ

trade-journal について

取引の成績や行動を体系的に振り返るトレーダー向けのジャーナルスキルです。取引の状況と結果を JSON または CSV に記録し、分析と行動パターン検出を行うスクリプトを備えています。

主な機能

  1. 01構造化された取引記録
  2. 02JSON 保存と CSV 出力
  3. 03戦略別の成績分析
  4. 04行動パターンの検出
  5. 05日次・週次・月次レビュー
  6. 06コマンドライン記録・分析スクリプト

活用シーン

  1. 01取引戦略ごとの成績比較
  2. 02リベンジトレードや FOMO の検出
  3. 03時間帯やトークン別の成績確認
  4. 04取引プロセスの変更効果の追跡

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/agiprolabs/claude-trading-skills --skill trade-journal

インストール後、Claude Code で/trade-journalを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
record_format.md
review_framework.md
scripts/
journal_analyzer.py
trade_logger.py

詳細

トレードジャーナル

体系的な改善のためのトレード記録です。すべてのトレードを状況とともに記録し、複数の頻度でパフォーマンスを振り返り、優位性を損なう行動パターンを検出し、リターンを特定の戦略に帰属させます。

ジャーナリングが重要な理由

多くのトレーダーが失敗する原因は、悪い戦略ではなく悪い行動です。トレードジャーナルを使うと、主観的な「感覚」を客観的なデータに変えられます。

  • 戦略の帰属分析:実際に利益を生むセットアップと、利益が出ているように感じるだけのセットアップを把握できます
  • 行動の検出:リベンジトレード、FOMOによるエントリー、早すぎる決済が積み重なる前に気づけます
  • パターンの認識:月曜の朝のトレードは損失になる、あるいはSOLの勝ちトレードを早く手仕舞いしすぎている、といった傾向を発見できます
  • 説明責任:エントリー前に根拠を書き出すことで、意識的な意思決定を促します
  • 改善の追跡:プロセスの変更が実際に結果を改善しているかを測定できます

ジャーナルがなければ、ノイズに基づいて最適化してしまいます。ジャーナルがあれば、シグナルに基づいて最適化できます。

トレード記録の構成

各トレード記録には、エントリー時の状況と決済時の結果が記録されます。18項目の完全なスキーマについては、references/record_format.md を参照してください。

最低限必要なフィールド
trade = {
    "id": "T-20250310-001",
    "token": "SOL",
    "direction": "long",
    "entry_date": "2025-03-10T14:30:00Z",
    "entry_price": 142.50,
    "size_sol": 5.0,
    "strategy": "momentum-breakout",
    "rationale": "Breaking above 4h resistance at 141.80 with volume confirmation",
    "exit_date": "2025-03-10T16:45:00Z",
    "exit_price": 146.20,
    "pnl_sol": 0.648,
    "outcome": "win",
    "lessons": "Held through initial pullback to 143.0, rewarded for patience"
}
戦略タグの付与

パフォーマンスの帰属分析ができるよう、一貫したタグを使用してください。

カテゴリータグ
モメンタムmomentum-breakout、trend-continuation、pullback-entry
平均回帰range-fade、oversold-bounce、deviation-snap
イベント主導listing-play、catalyst-trade、news-reaction
オンチェーンwhale-follow、wallet-copy、flow-signal
DeFilp-entry、yield-farm、arb-capture
根拠のテンプレート

エントリー前に根拠を書いてください。セットアップの種類別のテンプレート:

Momentum: "[Token] breaking [level] on [timeframe] with [confirmation]. Target [price], stop [price]."
Mean Reversion: "[Token] at [X] std devs from [mean] on [timeframe]. Expecting reversion to [target]."
On-Chain: "[Signal type] detected — [wallet/flow description]. Historical hit rate [X]%."

保存形式

ジャーナルでは、構造化されたクエリにはJSONを、スプレッドシートとの互換性にはCSVを使用します。

JSON形式(プライマリ)
{
  "journal_version": "1.0",
  "trader_id": "anon",
  "trades": [
    {
      "id": "T-20250310-001",
      "token": "SOL",
      "direction": "long",
      "entry_date": "2025-03-10T14:30:00Z",
      "entry_price": 142.50,
      "size_sol": 5.0,
      "size_usd": 712.50,
      "strategy": "momentum-breakout",
      "setup_quality": 8,
      "rationale": "Breaking above 4h resistance with volume",
      "exit_date": "2025-03-10T16:45:00Z",
      "exit_price": 146.20,
      "pnl_sol": 0.648,
      "pnl_pct": 2.60,
      "outcome": "win",
      "hold_time_minutes": 135,
      "emotional_state": "calm",
      "lessons": "Patience through pullback paid off",
      "tags": ["high-conviction", "clean-setup"]
    }
  ]
}
CSV形式(エクスポート)
id,token,direction,entry_date,entry_price,size_sol,strategy,exit_date,exit_price,pnl_sol,pnl_pct,outcome,lessons
T-20250310-001,SOL,long,2025-03-10T14:30:00Z,142.50,5.0,momentum-breakout,2025-03-10T16:45:00Z,146.20,0.648,2.60,win,"Patience paid off"

ジャーナルデータの分析

戦略別の勝率
from collections import Counter

def win_rate_by_strategy(trades: list[dict]) -> dict[str, float]:
    """Compute win rate grouped by strategy tag."""
    strategy_outcomes: dict[str, list[str]] = {}
    for t in trades:
        strat = t["strategy"]
        strategy_outcomes.setdefault(strat, []).append(t["outcome"])

    return {
        strat: outcomes.count("win") / len(outcomes)
        for strat, outcomes in strategy_outcomes.items()
        if len(outcomes) >= 5  # minimum sample size
    }
時間帯別のパフォーマンス
from datetime import datetime

def pnl_by_hour(trades: list[dict]) -> dict[int, float]:
    """Aggregate P&L by entry hour (UTC)."""
    hourly: dict[int, float] = {}
    for t in trades:
        hour = datetime.fromisoformat(t["entry_date"].rstrip("Z")).hour
        hourly[hour] = hourly.get(hour, 0.0) + t.get("pnl_sol", 0.0)
    return dict(sorted(hourly.items()))
トークンタイプ別のプロフィットファクター
def profit_factor(trades: list[dict], group_key: str = "token") -> dict[str, float]:
    """Compute profit factor (gross wins / gross losses) by grouping key."""
    groups: dict[str, dict[str, float]] = {}
    for t in trades:
        key = t.get(group_key, "unknown")
        groups.setdefault(key, {"wins": 0.0, "losses": 0.0})
        pnl = t.get("pnl_sol", 0.0)
        if pnl > 0:
            groups[key]["wins"] += pnl
        else:
            groups[key]["losses"] += abs(pnl)

    return {
        k: v["wins"] / v["losses"] if v["losses"] > 0 else float("inf")
        for k, v in groups.items()
    }

行動パターンの検出

ジャーナルを使うと、損失につながるトレードパターンを検出できます。詳細なフレームワークについては、references/review_framework.md を参照してください。

リベンジトレード

多くの場合、損失後にポジションサイズを大きくしてすぐ再エントリーします。

def detect_revenge_trades(trades: list[dict], max_gap_minutes: int = 15) -> list[dict]:
    """Find trades entered within max_gap_minutes of a losing exit."""
    sorted_trades = sorted(trades, key=lambda t: t["entry_date"])
    revenge = []
    for i in range(1, len(sorted_trades)):
        prev, curr = sorted_trades[i - 1], sorted_trades[i]
        if prev["outcome"] == "loss":
            prev_exit = datetime.fromisoformat(prev["exit_date"].rstrip("Z"))
            curr_entry = datetime.fromisoformat(curr["entry_date"].rstrip("Z"))
            gap = (curr_entry - prev_exit).total_seconds() / 60
            if gap <= max_gap_minutes:
                revenge.append(curr)
    return revenge
FOMOの検出

適切なセットアップがないまま、大きく動いた後にエントリーすることです。

  • エントリー根拠が曖昧、または記載されていない
  • セットアップの品質を自己評価で5/10未満としている
  • すでに1 ATRを超えて動いた相場でエントリーしている
利益の早期確定/損失の長期保有
def winner_loser_hold_times(trades: list[dict]) -> dict[str, float]:
    """Compare average hold time for wins vs losses."""
    win_times = [t["hold_time_minutes"] for t in trades if t["outcome"] == "win"]
    loss_times = [t["hold_time_minutes"] for t in trades if t["outcome"] == "loss"]
    return {
        "avg_win_hold_min": sum(win_times) / len(win_times) if win_times else 0,
        "avg_loss_hold_min": sum(loss_times) / len(loss_times) if loss_times else 0,
    }
    # RED FLAG: if avg_loss_hold > avg_win_hold, you're cutting winners and riding losers
ティルトの検出

損失後にポジションサイズが増加している場合、感情的なトレードが疑われます。

def detect_tilt(trades: list[dict], threshold: float = 1.5) -> list[dict]:
    """Flag trades where size increased >threshold after a loss."""
    tilt_trades = []
    for i in range(1, len(trades)):
        prev, curr = trades[i - 1], trades[i]
        if prev["outcome"] == "loss" and curr["size_sol"] > prev["size_sol"] * threshold:
            tilt_trades.append(curr)
    return tilt_trades

振り返りの頻度

毎日の振り返り(5分)
  • 今日のトレード数と損益は?
  • すべてのトレードでルールを守れたか?
  • 感情に左右された判断はあったか?
  • うまくできたことを1つ、改善することを1つ挙げる
毎週の振り返り(30分)
  • 戦略別の勝率とプロフィットファクター
  • 行動パターンの確認(リベンジトレード、ティルト、FOMO)
  • 今週のベストトレードとワーストトレード――違いを生んだ要因は?
  • 期待値と比較した戦略のパフォーマンス
  • 必要に応じてポジションサイズを調整する
毎月の振り返り(2時間)
  • 戦略の帰属分析全体
  • エクイティカーブの確認――ドローダウン期間と回復
  • トレードごとの実際のリスクと計画したリスクを比較する
  • トークンタイプ、時間帯、曜日別のパフォーマンス
  • 一貫して損失を出している戦略はあるか?停止を検討する
  • 戦略パラメーターを確認し、更新する

詳細な振り返りチェックリストと質問については、references/review_framework.md を参照してください。

部分決済と分割エントリー

実際のトレードでは、段階的なエントリーと決済が発生します。ジャーナルでは、子レコードを使ってこれらを記録します。

# Parent trade with two scale-out exits
parent = {
    "id": "T-20250310-001",
    "token": "BONK",
    "direction": "long",
    "entry_date": "2025-03-10T14:30:00Z",
    "entry_price": 0.000023,
    "size_sol": 10.0,
    "strategy": "momentum-breakout",
    "exits": [
        {"date": "2025-03-10T15:00:00Z", "price": 0.000025, "size_pct": 50, "reason": "first-target"},
        {"date": "2025-03-10T16:30:00Z", "price": 0.000028, "size_pct": 50, "reason": "trailing-stop"},
    ]
}

部分決済の扱いに関する詳細なドキュメントについては、references/record_format.md を参照してください。

ファイル

参考資料
  • references/record_format.md — 18 項目すべてを含む取引レコードのスキーマ、各項目の説明、タグ付けの分類体系、CSV/JSON の例、部分決済の処理
  • references/review_framework.md — 日次/週次/月次レビューのチェックリスト、行動面の危険信号、パフォーマンス低下の検出
スクリプト
  • scripts/trade_logger.py — CLI 取引記録ツール:追加、一覧表示、更新、統計の算出、フィルタリング、デモモード(標準ライブラリのみ)
  • scripts/journal_analyzer.py — ジャーナル分析:戦略のパフォーマンス、行動パターン、時間ベースの分析、デモモード(標準ライブラリのみ)

依存関係

どちらのスクリプトも Python の標準ライブラリ(json、datetime、argparse、collections)のみを使用します。外部パッケージは不要です。

# No installation needed — stdlib only
python scripts/trade_logger.py --demo
python scripts/journal_analyzer.py --demo

免責事項

このスキルは、取引記録の管理とパフォーマンス分析のためのツールを提供します。金融上の助言、取引の推奨、または取引成果の保証を行うものではありません。すべての分析は情報提供のみを目的としており、個人的な振り返りのためにのみご利用ください。

コメント