Trading Journal
/install trading-journal
Trading Journal — 交易日志管理
Record and analyze futures/stock trading journals. Supports structured trade logging, P&L tracking, performance analytics, and multi-format export.
Architecture
Trade Entry → [Journal] → Log → [Analysis] → Stats / Reports
↑ ↓
Template Driven Export (MD/CSV)
Core Workflows
Workflow 1: Log a Trade Entry
Use the standardized template to record a trade:
Template fields:
| Field | Description | Example |
|---|---|---|
| date | Trade date | 2026-05-20 |
| symbol | Contract/stock code | IF2606, 000001 |
| direction | Long or Short | long / short |
| entry_price | Entry price | 3850.0 |
| exit_price | Exit price | 3900.0 |
| quantity | Number of contracts/shares | 2 |
| multiplier | Contract multiplier (futures) | 300 |
| entry_time | Entry timestamp | 09:35 |
| exit_time | Exit timestamp | 14:20 |
| fees | Commission + slip | 45.60 |
| strategy | Strategy tag | trend_follow |
| notes | Free-text notes | "突破前高入场" |
| tags | Custom tags | ["股指", "日内"] |
Full JSON template:
{
"date": "2026-05-20",
"symbol": "IF2606",
"direction": "long",
"entry_price": 3850.0,
"exit_price": 3900.0,
"quantity": 2,
"multiplier": 300,
"entry_time": "09:35",
"exit_time": "14:20",
"fees": 45.60,
"strategy": "trend_follow",
"notes": "突破前高入场,尾盘止盈",
"tags": ["股指", "日内", "趋势"]
}
To log a trade:
- Ask user for trade details, or accept them in free-text format
- Map to the standard template
- Append to the daily journal file via the
scripts/trade_logger.pyscript - Calculate P&L and confirm with user
Workflow 2: Calculate P&L
Auto-calculated based on template fields:
Futures P&L:
P&L = (exit_price - entry_price) × quantity × multiplier × direction_sign - fees
Stock P&L:
P&L = (exit_price - entry_price) × quantity - fees
Where direction_sign = 1 for long, -1 for short.
The system handles:
- Open trades (no exit price — show unrealized P&L using current market price)
- Partial fills (quantity adjustments)
- Multi-leg strategies (aggregate P&L)
Workflow 3: Performance Analysis
Run analytics on journal entries using scripts/trade_analyzer.py:
Metrics computed:
| Metric | Formula |
|---|---|
| Win Rate | wins / total_closed × 100% |
| Total P&L | Σ(closed_trade_P&L) |
| Avg Win | Σ(win_P&L) / wins |
| Avg Loss | Σ(loss_P&L) / losses |
| Profit Factor | Σ(gross_profit) / Σ(gross_loss) |
| Sharpe Ratio | avg_return / std_return × √252 |
| Max Drawdown | Max peak-to-trough decline |
| Best/Worst Trade | Max/min single trade P&L |
| Daily Average | Total P&L / trading_days |
Analysis frequency:
- Daily: Quick summary of today's trades
- Weekly: Performance trends, strategy comparison
- Monthly: Full analytics report
- Custom: Any date range specified by user
Workflow 4: Archive & Search
Journal files are organized by date:
journals/
├── 2026/
│ ├── 2026-05/
│ │ ├── 2026-05-18.json # Day trades
│ │ ├── 2026-05-19.json
│ │ └── 2026-05-20.json
│ └── 2026-06/
│ └── 2026-06-01.json
└── archive/
└── 2025-journal.jsonl
Search across journals by:
- Date range (YYYY-MM-DD to YYYY-MM-DD)
- Symbol (e.g., IF, IC, CU)
- Direction (long/short)
- Strategy tag
- P&L range
- Custom text search in notes
Workflow 5: Export
Export journals to preferred format:
| Format | Use Case | Command |
|---|---|---|
| Markdown | Human-readable report, docs | python journal_export.py --format md --output report.md |
| CSV | Spreadsheet analysis, import | python journal_export.py --format csv --output trades.csv |
| JSON | Data interchange, backup | python journal_export.py --format json --output trades.json |
Usage Guide
A) Recording a New Trade
When user says "记一笔交易" or provides trade details:
- Parse trade info from user's natural language
- Confirm parsed fields with user
- Run:
python scripts/trade_logger.py add \x3Cjson_string> - Show calculated P&L and confirmation
Example interaction:
User: 今天IF2606做多2手,3850进场,3900平仓
Agent: 📓 记录交易:
IF2606 | LONG | 3850 → 3900 | 2手
P&L: (3900-3850)×2×300 - 费用 = ¥29,954.40
确认记录?(是/否)
B) Checking Performance
When user asks "看看收益" / "我的交易怎么样":
- Determine time range (today/this week/this month/custom)
- Run analyzer:
python scripts/trade_analyzer.py --range 2026-05-01 2026-05-20 - Present formatted results
Example output:
📊 交易绩效报告 (2026-05-01 ~ 2026-05-20)
━━━━━━━━━━━━━━━━━━━━━━━━━━━
总交易数: 24
胜率: 70.83% (17/24) 🟢
总盈亏: +¥186,520.00 🟢
平均盈利: +¥16,250.00
平均亏损: -¥4,830.00
盈亏比: 3.36
最大回撤: -¥12,400.00
最佳交易: +¥45,000.00 (IF2606, 05-08)
最差交易: -¥8,200.00 (IC2609, 05-12)
C) Exporting Data
When user asks to export:
- Confirm format and date range
- Run export script with appropriate parameters
- Show export path and summary
Scripts
scripts/trade_logger.py
Core trade logging — add, edit, delete, and list journal entries.
scripts/trade_analyzer.py
Performance analysis — compute metrics, generate reports for any date range.
scripts/journal_export.py
Multi-format export — output journals to Markdown, CSV, or JSON.
Special Notes
- Journal files are stored in
journals/directory within this skill folder - Each day gets one JSON file; multiple trades append to the same file
- P&L is calculated on entry, not just on display
- Open positions are tracked with
exit_price: nullandopen: true - All monetary values are in CNY (¥)
- Fees should include commission + slippage + stamp duty where applicable
- Journal data is local-only — no external API calls
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install trading-journal - 安装完成后,直接呼叫该 Skill 的名称或使用
/trading-journal触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Trading Journal 是什么?
Record and manage futures/stock trades with standardized templates, calculate P&L, analyze performance, search entries, and export journals in Markdown or CSV. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 44 次。
如何安装 Trading Journal?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install trading-journal」即可一键安装,无需额外配置。
Trading Journal 是免费的吗?
是的,Trading Journal 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Trading Journal 支持哪些平台?
Trading Journal 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Trading Journal?
由 zhaocaixia888(@zhaocaixia888)开发并维护,当前版本 v1.0.0。