Shadow Trading Dashboard
Dashboard Location
trade/dashboard/index.html — 影子盘看板主文件,双击用浏览器打开
Core Data Files
| File |
Purpose |
trade/dashboard/index.html |
Dashboard HTML |
trade/dashboard_data/metrics.json |
KPI metrics |
trade/dashboard_data/equity_curve.json |
Equity curve |
trade/data/positions.json |
Current positions |
trade/data/orders.jsonl |
Order log |
trade/trades.csv |
Open positions CSV |
trade/closed_positions.csv |
Closed positions CSV |
trade/trade_history.md |
Human-readable trade history |
Data Schema
positions.json
{
"symbol": "300274",
"name": "阳光电源",
"quantity": 300,
"cost": 163.16,
"current_price": 166.59,
"stop_loss": 160.00,
"tags": ["储能","龙头"],
"entry_reason": "储能龙头ROE29%,回调支撑买入"
}
metrics.json
{
"current_equity": 1001029.00,
"position_market_value": 49977.00,
"cash": 951037.32,
"unrealized_pnl": 1029.00,
"realized_pnl": 0.0,
"total_return_pct": 0.103,
"trade_count": 1,
"win_count": 0,
"loss_count": 0,
"max_drawdown": 0.0
}
Standard Workflows
Opening the Dashboard
open ~/.openclaw/workspace/trade/dashboard/index.html
After Any Trade (Buy/Sell/Stop)
- Update
trade/data/positions.json
- Append to
trade/data/orders.jsonl
- Update
trade/trades.csv and trade/closed_positions.csv
- Update
trade/dashboard_data/metrics.json
- Update
trade/dashboard_data/equity_curve.json
- Rebuild
trade/dashboard/index.html (update DATA object + equity curve)
- Update
trade/trade_history.md
- Run
open trade/dashboard/index.html
Building the Dashboard HTML
The dashboard is a self-contained HTML with an embedded DATA object. Key fields to update:
current_equity, cash, position_value, unrealized_pnl, realized_pnl
positions[] array (name, symbol, quantity, cost, current_price, stop_loss, tags)
trade_history[] array (date, time, symbol, name, action, direction, price, quantity, amount, fee, pnl, tags)
closed_positions[] for closed trades
equity_curve[] for the curve
Fees
- A股模拟手续费:0.03% 单边(买卖各收一次)
- Fee = price × quantity × 0.0003
Equity Calculation
current_equity = cash + Σ(position market value)
- Market value = current_price × quantity
Dashboard Update Checklist
After any trade, ALL of these must be updated:
1---2name: shadow-trading-dashboard3description: Shadow Trading Dashboard4---56# Shadow Trading Dashboard78## Dashboard Location9`trade/dashboard/index.html` — 影子盘看板主文件,双击用浏览器打开1011## Core Data Files1213| File | Purpose |14|------|---------|15| `trade/dashboard/index.html` | Dashboard HTML |16| `trade/dashboard_data/metrics.json` | KPI metrics |17| `trade/dashboard_data/equity_curve.json` | Equity curve |18| `trade/data/positions.json` | Current positions |19| `trade/data/orders.jsonl` | Order log |20| `trade/trades.csv` | Open positions CSV |21| `trade/closed_positions.csv` | Closed positions CSV |22| `trade/trade_history.md` | Human-readable trade history |2324## Data Schema2526### positions.json27```json28{29 "symbol": "300274",30 "name": "阳光电源",31 "quantity": 300,32 "cost": 163.16,33 "current_price": 166.59,34 "stop_loss": 160.00,35 "tags": ["储能","龙头"],36 "entry_reason": "储能龙头ROE29%,回调支撑买入"37}38```3940### metrics.json41```json42{43 "current_equity": 1001029.00,44 "position_market_value": 49977.00,45 "cash": 951037.32,46 "unrealized_pnl": 1029.00,47 "realized_pnl": 0.0,48 "total_return_pct": 0.103,49 "trade_count": 1,50 "win_count": 0,51 "loss_count": 0,52 "max_drawdown": 0.053}54```5556## Standard Workflows5758### Opening the Dashboard59```bash60open ~/.openclaw/workspace/trade/dashboard/index.html61```6263### After Any Trade (Buy/Sell/Stop)641. Update `trade/data/positions.json`652. Append to `trade/data/orders.jsonl`663. Update `trade/trades.csv` and `trade/closed_positions.csv`674. Update `trade/dashboard_data/metrics.json`685. Update `trade/dashboard_data/equity_curve.json`696. Rebuild `trade/dashboard/index.html` (update DATA object + equity curve)707. Update `trade/trade_history.md`718. Run `open trade/dashboard/index.html`7273### Building the Dashboard HTML74The dashboard is a self-contained HTML with an embedded DATA object. Key fields to update:75- `current_equity`, `cash`, `position_value`, `unrealized_pnl`, `realized_pnl`76- `positions[]` array (name, symbol, quantity, cost, current_price, stop_loss, tags)77- `trade_history[]` array (date, time, symbol, name, action, direction, price, quantity, amount, fee, pnl, tags)78- `closed_positions[]` for closed trades79- `equity_curve[]` for the curve8081### Fees82- A股模拟手续费:0.03% 单边(买卖各收一次)83- Fee = price × quantity × 0.00038485### Equity Calculation86- `current_equity` = cash + Σ(position market value)87- Market value = current_price × quantity8889## Dashboard Update Checklist90After any trade, ALL of these must be updated:91- [ ] `trade/data/positions.json`92- [ ] `trade/data/orders.jsonl` (append new order)93- [ ] `trade/trades.csv` (open positions)94- [ ] `trade/closed_positions.csv` (closed positions)95- [ ] `trade/dashboard_data/metrics.json`96- [ ] `trade/dashboard_data/equity_curve.json`97- [ ] `trade/dashboard/index.html` (DATA object + equity_curve)98- [ ] `trade/trade_history.md`