# Trading Audit Dashboard

> >

- **Type:** Skill
- **Install:** `agentstack add skill-vishalmdi-trading-audit-dashboard-trading-audit-dashboard`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [vishalmdi](https://agentstack.voostack.com/s/vishalmdi)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [vishalmdi](https://github.com/vishalmdi)
- **Source:** https://github.com/vishalmdi/trading-audit-dashboard

## Install

```sh
agentstack add skill-vishalmdi-trading-audit-dashboard-trading-audit-dashboard
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Trading Audit Dashboard Skill v2.0

Produces a full forensic trading performance audit as a single self-contained HTML dashboard.
Covers 7 phases: Executive Dashboard, Strategy Reverse-Engineering, Behavioral Forensics,
Advanced Analytics (NEW), Monte Carlo Forecasting, Professional Recommendations, and JSON Export.

---

## Step 1 — Identify Input Format and Extract Trade Data

Read the uploaded file(s). Supported formats:
- **PDF** (broker statements like Trading 212, eToro, IBKR) → use pdfplumber
- **CSV** → parse with pandas/csv
- **XLSX** → use openpyxl or pandas
- **JSON** → load directly

### For PDF Statements (most common)

```python
import pdfplumber

with pdfplumber.open('file.pdf') as pdf:
    all_text = {}
    for i, page in enumerate(pdf.pages):
        all_text[i+1] = page.extract_text() or ''
```

Scan pages for CFD / derivatives trade tables. Look for pages containing:
- Keywords: `executed trades`, `CFD`, `closed`, `realized`, `settlement`
- Column headers: `DIRECTION`, `BUY/SELL`, `QUANTITY`, `PRICE`, `RESULT`, `P&L`, `PROFIT`

**Skip** Invest/equity account pages — only process CFD/derivatives/futures/forex closed trades.

### Key Parsing Rules

For **Trading 212** format:
- Opening entries have `-` in the Average Price column → **skip these**
- Closing entries have a populated Average Price → **include these**
- TOTAL RESULT is the **last** EUR/USD amount on the line (after FX Fee, Result, Div Adj, OI)
- Sign is literal in the text: `€64.25` = profit, `€-32.10` = loss

For **generic CSV/XLSX**:
- Look for columns: `profit`, `pnl`, `realized_pnl`, `net_result`, `closed_pnl`
- Parse `open_time`/`close_time` for hold duration
- Extract `volume`/`lots`/`quantity` for position size analysis
- Extract `swap` / `commission` / `spread` fields if present (used by cost drag analysis)

### Minimum Required Fields Per Trade

```python
trade = {
    'date': 'YYYY-MM-DD',
    'time': 'HH:MM:SS',          # or '00:00:00' if unavailable
    'datetime': 'YYYY-MM-DD HH:MM:SS',
    'direction': 'Buy' | 'Sell',
    'instrument': 'XAUUSD',      # ticker/symbol
    'size': 2,                   # lots/units/quantity
    'total_result': 64.25,       # signed float, positive=profit
    'order_type': 'Limit',       # optional
    'swap_cost': 0.0,            # optional — overnight financing (negative = cost)
    'spread_cost': 0.0,          # optional — spread/commission drag
}
```

Save to `/home/claude/parsed_trades.json`.

---

## Step 2 — Compute All Statistics

Run `scripts/compute_stats.py` on the parsed trades.
If the script is unavailable, compute inline using the formulas in `references/statistics.md`.

The script now computes **all v2.0 metrics** automatically:

### Core Metrics (unchanged)
- Win rate, avg win/loss, profit factor, expectancy, net P&L, max win/loss, trades/day

### Session / DOW / Size / Order Type (unchanged)
- Asian/London/NY session stats; Mon–Fri day-of-week; position size buckets; order type comparison

### Sharpe Ratio & Max Drawdown (unchanged)
- Annualised Sharpe; max drawdown in currency and percent

### Monte Carlo (unchanged)
- 10,000 simulations × remaining months of year; P10/P50/P90 projections

### v2.0 NEW Metrics

**Wilson Confidence Interval on Win Rate**
```python
# Formula in references/statistics.md → 'win_rate_ci' key
# Output: lower, upper, label, note
# Always display alongside win rate — critical for small samples ( 1 instrument detected)
```python
# 'instrument_matrix' key: instruments{}, best_by_sharpe, worst_by_sharpe
```

**Transaction Cost / Swap Drag**
```python
# 'cost_drag' key: total_swap_cost, total_spread_cost, total_cost_drag,
#   cost_pct_of_gross, estimated (bool), note
```

---

## Step 3 — Determine Starting Equity

Look in the broker statement for:
- Trading 212: `Account value` in the CFD section of the Overview
- IBKR: `Net Asset Value` or `Starting Cash`
- eToro: `Account Balance` at period start
- MetaTrader: `Balance` at start of statement period
- If unavailable: estimate as `abs(net_pnl) / 0.20` or ask user

---

## Step 4 — Generate the HTML Dashboard

Read `assets/dashboard_template.html` for the full visual design system.

Substitute all `{{PLACEHOLDER}}` values with computed statistics.

### Existing Placeholders (unchanged from v1.0)

| Placeholder | Value |
|---|---|
| `{{TRADER_NAME}}` | From statement header or "Trader" |
| `{{ACCOUNT_ID}}` | From statement or "N/A" |
| `{{BROKER}}` | Detected broker name |
| `{{INSTRUMENT}}` | Primary instrument(s) traded |
| `{{PERIOD_START}}` | Earliest trade date |
| `{{PERIOD_END}}` | Latest trade date |
| `{{TRADING_DAYS}}` | Count of distinct trading dates |
| `{{TOTAL_TRADES}}` | len(trades) |
| `{{NET_PROFIT}}` | net_pnl formatted as currency |
| `{{WIN_RATE}}` | e.g. "89.0%" |
| `{{PROFIT_FACTOR}}` | e.g. "3.26" |
| `{{MAX_DRAWDOWN}}` | e.g. "€177" |
| `{{EXPECTANCY}}` | e.g. "€11.75" |
| `{{SHARPE}}` | e.g. "16.12" |
| `{{AVG_WINNER}}` | e.g. "€19.05" |
| `{{AVG_LOSER}}` | e.g. "€47.33" |
| `{{EQUITY_LABELS}}` | JS array of date strings |
| `{{EQUITY_DATA}}` | JS array of running equity floats |
| `{{STARTING_EQUITY}}` | Float |
| `{{SCENARIO_*}}` | Bear/Base/Bull monthly projections |
| `{{SESSION_*}}` | Asian/London/NY stats |
| `{{DOW_*}}` | Mon–Fri stats |
| `{{SIZE_TABLE_ROWS}}` | HTML table rows |
| `{{CURRENT_EQUITY}}` | Starting + net_pnl |
| `{{RETURN_PCT}}` | Return % |

### v2.0 New Placeholders

| Placeholder | Value |
|---|---|
| `{{WIN_RATE_CI}}` | e.g. "76–96% (95% CI)" |
| `{{WIN_RATE_CI_NOTE}}` | Full CI note string |
| `{{KELLY_HALF}}` | e.g. "12.3%" |
| `{{KELLY_FULL}}` | e.g. "24.7%" |
| `{{KELLY_NOTE}}` | Full Kelly recommendation text |
| `{{ROR_PCT}}` | e.g. "0.23%" |
| `{{ROR_2X_PCT}}` | e.g. "3.84%" (at double lot size) |
| `{{ROR_NOTE}}` | Full RoR note |
| `{{DD_RECOVERY_TRADES}}` | e.g. "15" |
| `{{DD_RECOVERY_DAYS}}` | e.g. "3.0" |
| `{{MAX_LOSS_STREAK}}` | e.g. "3" |
| `{{TILT_DETECTED}}` | "Yes ⚠️" or "No ✅" |
| `{{TILT_DETAIL}}` | Tilt detail string |
| `{{CURRENT_STREAK}}` | e.g. "5 wins" or "2 losses" |
| `{{HOT_10_PNL}}` | Best rolling 10-trade P&L |
| `{{COLD_10_PNL}}` | Worst rolling 10-trade P&L |
| `{{ROLLING_TREND}}` | "📈 Improving" / "📉 Declining" / "➡️ Stable" |
| `{{ROLLING_30D_WR}}` | 30-day win rate % |
| `{{ROLLING_60D_WR}}` | 60-day win rate % |
| `{{ROLLING_90D_WR}}` | 90-day win rate % |
| `{{ROLLING_30D_PF}}` | 30-day profit factor |
| `{{HOURLY_HEATMAP_DATA}}` | JS array of {hour, avg_pnl, trades} for Chart.js |
| `{{BEST_HOUR}}` | e.g. "09:00 UTC" |
| `{{WORST_HOUR}}` | e.g. "14:00 UTC" |
| `{{INST_MATRIX_ROWS}}` | HTML rows for instrument comparison table (or "N/A" if single) |
| `{{COST_DRAG_TOTAL}}` | e.g. "€28.40" |
| `{{COST_DRAG_PCT}}` | e.g. "4.2%" of gross |
| `{{COST_DRAG_NOTE}}` | Full cost drag note |
| `{{OVERCONFIDENCE_DETECTED}}` | "Yes ⚠️" or "No ✅" |

### New Dashboard Sections to Add

After the existing Behavioral Forensics section, add these new panels:

**Panel: Advanced Analytics — Kelly & Risk of Ruin**
```html

```

**Panel: Rolling Performance Trend**
```html

```

**Panel: Hourly P&L Heatmap** (only if time data available)
```html

```

**Panel: Streak & Momentum**
```html

```

**Panel: Multi-Instrument Matrix** (only if > 1 instrument)
```html

```

**Panel: Transaction Cost Drag**
```html

```

---

## Step 5 — Vulnerability Scorecard Logic (unchanged)

Rate each dimension with 🟢/🟡/🔴 using these rules:

| Dimension | 🟢 Green | 🟡 Yellow | 🔴 Red |
|---|---|---|---|
| Stop-Loss Discipline | Max loss  5× avg loss |
| Position Sizing | All sizes positive | One size bucket negative | Multiple size buckets negative |
| Over-Trading | Worst day WR > 85% | Worst day WR 80–85% | Worst day WR  3.0 | PF 1.5–3.0 | PF  88% rolling | WR 82–88% | WR  1 instrument
- [ ] Cost drag panel shows "estimated" flag when applicable
- [ ] Streak analytics panel shows current streak + hot/cold windows
- [ ] Recommendations are specific and quantified, not generic
- [ ] JSON stats file saved alongside HTML
- [ ] Dashboard footer shows trade count, date range, and "v2.0" label

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [vishalmdi](https://github.com/vishalmdi)
- **Source:** [vishalmdi/trading-audit-dashboard](https://github.com/vishalmdi/trading-audit-dashboard)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-vishalmdi-trading-audit-dashboard-trading-audit-dashboard
- Seller: https://agentstack.voostack.com/s/vishalmdi
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
