Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
python-version: "3.12"
- name: Validate plugin structure
run: python3 tests/validate.py
- name: Hook and content tests
run: |
python3 tests/test_hooks.py
python3 tests/test_content.py

smoke-mcp:
name: Live MCP smoke test
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ All notable changes to the CPZAI plugin are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.0] - 2026-11-25

### Fixed
- The pre-trade guard and the audit log never ran: they matched `mcp__cpzai__*`, while Claude Code names this plugin's tools `mcp__plugin_cpzai_cpzai__*`. The hooks now match both spellings, and every `allowed-tools`, `tools` and `disallowedTools` list uses the plugin names, so the agents can reach the CPZAI tools at all (cpzai#2908).
- The guard blocked every order and strategy run with "ask the user and re-issue", keeping no record of the answer, so a confirmed call was blocked again. It now answers `permissionDecision: "ask"`: Claude Code shows the call once with a summary and runs it when the user approves (cpzai#2908). It is now `scripts/pre_trade_guard.py`.
- The audit log recorded `ok: true` for every call (it read a `success` field PostToolUse does not send). It now reads the tool's answer and records `null` when the answer does not say.
- `/backtest` and the backtesting, strategy-development and alpha-research skills sent Claude to `execute_strategy` to backtest. That tool runs the strategy's code and can submit orders. `/backtest` now reads saved runs only and says runs start in CPZAI Strategy Lab; the quant-researcher agent can no longer call `execute_strategy` (cpzai#2797).
- Equity, cash and buying power came from `list_accounts`, which holds no balances. Commands, skills and agents now use `cash_summary` (cpzai#2906).
- Commands and skills asked for figures no tool returns (IV, Greeks, P/E, ROE, sector and factor exposure, week and month P&L, margin used) and pointed history-based figures (52-week range, moving averages, RSI, relative volume, per-holding beta and volatility, covariance) at the quote or the risk check. History now comes from `get_bars`; every command says to write "not available from CPZAI" for the rest, never fill it from memory; CONNECTORS.md lists what each tool returns (cpzai#2886, cpzai#2909).

- The audit log (now `scripts/audit_log.py`) logged a refused order as ok, kept no broker reply, skipped calls that failed outright and cut the input at 240 characters. It now records refusals with their reason, the broker's order id and status, failed calls (PostToolUseFailure), and the whole input with credential fields redacted (cpzai#3024).
- The risk-management skill's risk contributions had an extra weight and added up to far more than 100%; portfolio-optimization described risk parity with the minimum-variance condition; strategy-development said inverse volatility equalizes risk contribution without the equal-correlation condition (cpzai#3012).
- Six formulas and rules: risk reversal sign, breadth, factor model parameter count, what scikit-learn's Ledoit-Wolf shrinks toward, the trade count for a meaningful backtest, and /trade-idea's expected value leaving out the worst case (cpzai#3022).
- SEC Rule 17a-4 retention: order memoranda 3 years, blotters and ledgers 6 (cpzai#3023).
- `/trade` takes a stop price, takes shares only, says orders are day orders, shows the limit and stop before approval, and never resends after a timeout; order-execution no longer offers GTC, IOC, FOK, extended hours, trailing or bracket orders through `place_order` (cpzai#3014, cpzai#3034).
- `/strategy-builder` writes the format Strategy Lab backtests: `SYMBOLS` and one module-level `generate_signals`, `generate_signal` or `on_bar` (cpzai#3013).
- `/positions`, `/portfolio-review`, `/risk-report` and `/orders` page until a short page instead of treating one page as the whole book (cpzai#3037).
- The pre-trade guard fails closed: empty or malformed events, unrecognised tool names and errors inside the guard are asked about instead of passing. The session banner reads the confirmation option as the guard does and says when python3 is missing.

### Added
- `tests/test_hooks.py` and `tests/test_content.py`, run by `tests/run-all.sh` and CI.

## [2.0.0] — 2026-04-30

State-of-the-art upgrade aligning the plugin with the current Claude Code / Cowork plugin specification.
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![Claude Cowork](https://img.shields.io/badge/Claude-Cowork-000000?logo=anthropic&logoColor=white)](https://claude.com/product/cowork)
[![Claude Code](https://img.shields.io/badge/Claude-Code-000000?logo=anthropic&logoColor=white)](https://claude.com/product/claude-code)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue)](cpzai/LICENSE)
[![Version](https://img.shields.io/badge/Version-2.0.0-blue)]()
[![Version](https://img.shields.io/badge/Version-2.1.0-blue)]()
[![Skills](https://img.shields.io/badge/Skills-10-green)]()
[![Commands](https://img.shields.io/badge/Commands-17-green)]()
[![Agents](https://img.shields.io/badge/Agents-3-green)]()
Expand Down Expand Up @@ -76,7 +76,7 @@ Claude Code prompts for your CPZ API key and secret on first use. To re-configur
| Command | Description |
|---------|-------------|
| `/cpzai:strategy-builder` | Guided strategy creation — describe a trading idea and Claude writes the code |
| `/cpzai:backtest` | Run a strategy backtest, analyze metrics, and identify improvements |
| `/cpzai:backtest` | Analyze a strategy's saved backtest runs and identify improvements (runs start in CPZAI Strategy Lab) |
| `/cpzai:risk-report` | Generate a risk report — VaR, Sharpe, drawdown, with recommendations |
| `/cpzai:portfolio-review` | Full portfolio health check — positions, diversification, attribution |
| `/cpzai:market-scan` | Scan sectors or themes with real-time quotes and context |
Expand Down Expand Up @@ -126,14 +126,14 @@ Read-only by design: `risk-auditor` and `execution-reviewer` cannot place orders

## MCP Tools

The CPZAI MCP server provides 18 tools across 8 categories. Every tool carries a safety annotation (`readOnlyHint`, or `destructiveHint`) per the MCP specification.
The CPZAI MCP server's main tools are below (`tools/list` has the full catalog). Every tool carries a safety annotation (`readOnlyHint`, or `destructiveHint`) per the MCP specification. [CONNECTORS.md](cpzai/CONNECTORS.md#what-the-tools-return-and-what-they-do-not) lists what each tool returns and which figures no tool provides.

| Category | Read-Only | Write | Destructive |
|----------|-----------|-------|-------------|
| Strategies | `list_strategies`, `get_strategy` | `create_strategy`, `update_strategy` | — |
| Backtesting | `get_backtest_results` | — | — |
| Trading | `list_orders`, `list_positions`, `list_accounts` | `sync_portfolio` | `place_order` |
| Market Data | `get_market_data` | — | — |
| Backtesting | `get_backtest_results`, `get_backtest_result` (saved runs; no tool starts one) | | |
| Trading | `list_orders`, `list_positions`, `list_accounts`, `cash_summary`, `export_transactions` | `sync_portfolio` | `place_order` |
| Market Data | `get_market_data`, `get_bars` | | |
| Risk | `list_risk_snapshots` | `compute_risk` | — |
| Execution | — | — | `execute_strategy` |
| Webhooks | `list_webhooks` | `create_webhook` | `delete_webhook` |
Expand Down Expand Up @@ -177,7 +177,7 @@ The `risk-auditor` agent pulls live positions, computes current VaR/Sharpe/drawd
/cpzai:backtest my momentum strategy from 2020-01 to 2024-12 with weekly rebalance
```

Runs the backtest, analyzes results (Sharpe, max drawdown, win rate), checks robustness across sub-periods, and suggests parameter improvements grounded in the `backtesting` skill.
Finds the saved run for that period in your CPZAI account, analyzes it (Sharpe, max drawdown, win rate), checks robustness across sub-periods, and suggests parameter improvements grounded in the `backtesting` skill. No plugin tool starts a backtest: run it in CPZAI Strategy Lab first.

### Place a guarded order

Expand Down Expand Up @@ -210,7 +210,7 @@ The `cpzai/.mcp.json` config wires `userConfig` values into HTTP headers automat
"headers": {
"X-CPZ-Key": "${user_config.cpz_api_key}",
"X-CPZ-Secret": "${user_config.cpz_api_secret}",
"X-CPZ-Client": "claude-plugin/2.0.0"
"X-CPZ-Client": "claude-plugin/2.1.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cpzai/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
"name": "cpzai",
"version": "2.0.0",
"version": "2.1.0",
"description": "AI-native systematic trading — build strategies, backtest, manage risk, and execute trades. Connects to CPZAI for live portfolio, market data, and order management.",
"author": {
"name": "CPZ Lab",
Expand Down
2 changes: 1 addition & 1 deletion cpzai/.mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"headers": {
"X-CPZ-Key": "${user_config.cpz_api_key}",
"X-CPZ-Secret": "${user_config.cpz_api_secret}",
"X-CPZ-Client": "claude-plugin/2.0.0"
"X-CPZ-Client": "claude-plugin/2.1.0"
}
}
}
Expand Down
Loading
Loading