From quant-paper-agent
Translate a validated vectorized backtest (papers/<arxiv-id>/code/) into a production event-driven strategy file for the team's live-trading framework. Use this skill ONLY after paper-replicate has produced a stable backtest and a benchmark.md verdict the user trusts, AND after the event-driven framework spec has been filled in at references/framework_spec.md. This skill ships in PLACEHOLDER mode — it will refuse to generate code until framework_spec.md contains real framework contracts (event types, function signatures, position API). Bundles a production-grade size_contracts() function and its unit tests for notional-to-contracts conversion with margin checks — the money-losing bug class that must be unit-tested before any live deployment.
How this skill is triggered — by the user, by Claude, or both
Slash command
/quant-paper-agent:strategy-translateThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Fourth stage of the paper-to-production pipeline. Converts a validated vectorized backtest into an event-driven strategy file.
Fourth stage of the paper-to-production pipeline. Converts a validated vectorized backtest into an event-driven strategy file.
The vectorized → event-driven translation depends on your team's specific event-driven framework (event types, function signatures, order and position API, clock handling). Rather than guess, this skill refuses to emit strategy code until references/framework_spec.md is filled in with real contracts.
Run:
python scripts/check_spec.py
It will exit non-zero and tell you exactly what the spec must include. Once framework_spec.md is filled in, re-run.
Requires Python ≥ 3.9 and pytest (for the bundled sizing tests); install via the plugin's root requirements.txt.
papers/<arxiv-id>/code/backtest.py exists and benchmark.md says at least "partially replicated" with medium+ confidence.Once the spec is real, the translator maps vectorized operations into the event loop:
| Vectorized idiom | Event-driven equivalent |
|---|---|
prices.pct_change() | track last close per symbol, compute on new bar |
weights.shift(1) * returns | apply prior-bar weight to realized P&L on on_bar |
signal.rolling(L).mean() | maintain an online rolling buffer of length L |
rebalance daily | schedule on every on_bar end-of-day event |
Generated files land in papers/<arxiv-id>/strategy/:
strategy.py — the event-driven implementation.sizing.py — imports size_contracts from this skill's bundled script.tests/test_strategy.py — minimum: sizing unit tests + one bar-replay sanity test.Even though translation is a placeholder, the sizing math is NOT — it ships fully implemented at scripts/size_contracts.py with unit tests at scripts/tests/test_size_contracts.py. Run:
python -m pytest scripts/tests/test_size_contracts.py -v
The tests MUST pass before any strategy goes live. Sizing errors cost real money.
def size_contracts(target_notional, price, multiplier,
margin_rate, available_capital):
contracts = round(target_notional / (price * multiplier))
margin_required = abs(contracts) * price * multiplier * margin_rate
if margin_required > available_capital:
scale = available_capital / margin_required
contracts = int(contracts * scale)
return contracts
Handles:
framework_spec.md.test_size_contracts.py.strategy.py must include its own smoke test that replays at least one historical day of bars and asserts P&L within a tolerance of the vectorized backtest — otherwise translation errors slip into production.npx claudepluginhub lucaswychan/quant-paper-agent --plugin quant-paper-agentProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.