Status: proposed Date: 2026-03-27
Add the trading risk calculator into the QuantLab ecosystem as an auxiliary pre-trade and risk-planning tool, not as part of the central backtest or execution engine.
The target product shape is:
- QuantLab remains the sovereign CLI-first research and execution system
- the calculator evolves into a reusable pre-trade workbench
- the workbench produces deterministic artifacts that QuantLab can consume
- the UI remains an optional operator surface, never the owner of policy
This integration should not place calculator logic inside:
backteststrategiesexecution- venue adapters
Instead, it should introduce a bounded auxiliary subsystem:
pretrade
This subsystem should sit beside QuantLab's main research and execution flow and support operator decisions before paper or broker-facing actions occur.
Recommended product name:
QuantLab Pre-Trade Risk Workbench
Recommended responsibility:
- size a position from capital, risk percent, entry, stop, and target
- estimate fees and slippage impact
- validate pre-trade policy assumptions before submit
- generate deterministic trade-plan artifacts
- optionally derive a draft
ExecutionIntent, but never submit directly
The workbench must be invokable through QuantLab's CLI and/or machine-facing request surface.
The canonical output should be a pre-trade artifact directory, not UI state.
Suggested root:
outputs/pretrade_sessions/<session_id>/
Suggested files:
outputs/pretrade_sessions/<session_id>/
input.json
plan.json
summary.json
plan.md
The UI may:
- visualize plans
- compare scenarios
- browse saved artifacts
- show policy rejection reasons
The UI must not:
- own risk policy
- decide execution authority
- submit directly to venue adapters
QuantLab should consume the workbench through narrow contracts that remain useful even if the UI or calculator implementation changes later.
Recommended contract marker:
contract_type = "quantlab.pretrade.plan"
Suggested minimum fields:
session_idsymbolvenuesideentry_pricestop_pricetarget_pricerisk_amountrisk_percentposition_sizeestimated_feesestimated_slippagenotionalpolicy_checksdraft_execution_intent
QuantLab should own:
- the
pretradepackage - CLI entrypoints
- artifact writing and validation
- safety-boundary bridging into
ExecutionPolicyandExecutionIntent
The calculator repository should own:
- operator-friendly scenario planning UX
- reusable risk-calculation logic
- fixture parity with any alternate runtime implementations
- export surfaces that are convenient for QuantLab ingestion
Do not:
- merge this into the backtest engine
- treat the calculator as the owner of execution policy
- let the UI become the path that governs broker submission
- use this feature to bypass the broker safety boundary
- publish this roadmap
- define the product boundary
- align follow-up issues across QuantLab and calculator repos
- add
src/quantlab/pretrade/ - implement deterministic plan generation
- persist canonical artifact directories under
outputs/pretrade_sessions/
- convert pre-trade plans into draft
ExecutionIntent - validate them against
ExecutionPolicy - surface deterministic rejection reasons before adapter interaction
- expose artifact browsing and scenario comparison in
research_ui - keep the surface read-only or narrowly bounded
- preserve QuantLab CLI and core as the authority
QuantLab gains a useful pre-trade planning subsystem that improves operator discipline and execution readiness without turning the calculator or UI into the center of the product.