feat(lean): native LEAN CLI engine executor + LEAN GUI surface - #1256
Open
bishallllllll wants to merge 13 commits into
Open
feat(lean): native LEAN CLI engine executor + LEAN GUI surface#1256bishallllllll wants to merge 13 commits into
bishallllllll wants to merge 13 commits into
Conversation
- src/domain/lean/: full adapter layer (types, config-gen, data-converter, results, service, algorithms, experiments, journal, research-integrity/) - src/tool/lean.ts: 8 typed AI tools registered via ToolCenter - src/webui/routes/lean.ts: REST API for Quant Lab (/api/lean/*) - ui/src/api/lean.ts: typed frontend API client - ui/src/pages/: QuantLabPage, StrategyDetailPage, BacktestResultsPage, ResearchIntegrityPage, TradeJournalPage - ui/src/components/lean/: LeanEquityCurve, BacktestMetricsGrid, ResearchIntegrityCards, QuantLabSidebar, TradeLogTable - Python QCAlgorithm templates: ema-cross.py, london-breakout.py, rsi-mean-reversion.py - Evidence-first research integrity: oos.ts, walk-forward.ts, monte-carlo.ts, sensitivity.ts, data-snooping.ts - 30+ unit tests in src/domain/lean/__tests__/ Additive only: 6 existing files modified with ~50 lines of additive hooks. Zero deletions. lean.enabled: false by default. Quant Lab gated — disabled state shown until lean.enabled: true.
LeanService now executes backtests with the QuantConnect lean CLI (lean backtest <project> --output ...) when the binary is installed, scaffolding a per-run project (lean.json + algorithm) under data/lean/runs/*/project. Engine results (orders, charts, stats, closed trades) are parsed from the current LEAN output shape with a backward-compatible dual-format parser; the summary statistics dict is merged over the full result. Timed-out runs kill the CLI and sweep engine containers by image + creation window so nothing is orphaned. A Docker-based runner remains as the automatic fallback for machines without the lean CLI. The quant-lab skill now documents the executor.
…LEAN GUI The native QuantConnect lean CLI is now a first-class surface: a checkLeanCli probe feeds /api/lean/config and /api/lean/status, the new leanStatus tool backs 'alice-quant system status', and the Chat workspace instruction lists the lean CLI next to alice-quant with a quant-lab playbook row. Visible UI chrome (tab titles, page headers, sidebar, navigation labels and all four locale catalogs) reads LEAN GUI while stable quant-lab route IDs remain unchanged. quant-lab is also bundled with every tool-bearing workspace via the CLI skills injector, and the CLI export manifests describe the renamed surface.
Replaces literal palette hex values and palette utility classes (emerald/blue/purple/amber variants) in the LEAN UI with the semantic chart tokens and success/warning/destructive roles so every palette card renders consistently. Keeps the semantic color contract audit green and updates the ui-layout catalog expectation for the quant-lab entry.
|
@luokerenx4 is attempting to deploy a commit to the luokerenx4's Team Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR completes the QuantConnect LEAN integration by adding a full /api/lean/* WebUI backend plus a “LEAN GUI” frontend surface (while keeping the stable /quant-lab route IDs), and wires the feature into workspace tooling via the alice-quant CLI and quant-lab skill injection.
Changes:
- Add LEAN WebUI routes for config/status plus templates, strategies, backtests, experiments/optimization, integrity, journal, and data ingest.
- Add the “LEAN GUI” UI surface (navigation, tab registry/routing, layout defaults, and i18n labels) anchored at
/quant-lab. - Bundle “quant-lab” as a tool-bearing workspace skill and add
alice-quantCLI launchers.
Reviewed changes
Copilot reviewed 156 out of 161 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ui/src/tabs/UrlAdopter.tsx | Adds /quant-lab/* routes and maps quant-lab view specs into the correct activity section. |
| ui/src/tabs/types.ts | Extends ViewSpec and ActivitySection to include quant-lab view kinds. |
| ui/src/tabs/registry.tsx | Registers quant-lab view modules and maps them to pages/titles/URLs. |
| ui/src/live/ui-layout.ts | Adds quant-lab into the default UI layout (Beta group). |
| ui/src/live/ui-layout.spec.ts | Updates layout expectations to include quant-lab. |
| ui/src/i18n/locales/en.ts | Adds “LEAN GUI” nav label for quant-lab. |
| ui/src/i18n/locales/ja.ts | Adds “LEAN GUI” nav label for quant-lab. |
| ui/src/i18n/locales/zh.ts | Adds “LEAN GUI” nav label for quant-lab. |
| ui/src/i18n/locales/zh-Hant.ts | Adds “LEAN GUI” nav label for quant-lab. |
| ui/src/components/lean/BacktestMetricsGrid.tsx | Adds a metrics grid component to display key backtest statistics. |
| ui/src/components/ActivityBar.tsx | Maps the new quant-lab page into the activity section model. |
| ui/src/components/ActivityBar.spec.ts | Updates navigation hierarchy expectations to include LEAN GUI in Beta. |
| ui/src/components/activity-navigation.ts | Adds the quant-lab rail item (icon + default tab). |
| ui/src/App.tsx | Extends the Page union to include quant-lab. |
| src/workspaces/templates/chat/files/instruction.md | Documents alice-quant + native lean CLI surfaces for workspaces. |
| src/workspaces/context-injector.ts | Injects quant-lab skill into tool-bearing workspaces. |
| src/workspaces/context-injector.spec.ts | Updates expectations for injected skills to include quant-lab. |
| src/workspaces/cli/bin/alice-quant.cmd | Adds Windows launcher for alice-quant. |
| src/workspaces/cli/bin/alice-quant | Adds POSIX launcher for alice-quant. |
| src/webui/routes/lean.ts | Implements /api/lean/* backend routes for LEAN GUI feature set. |
| src/webui/routes/tests/lean.spec.ts | Adds route-level tests for the LEAN WebUI API surface. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+61
to
+78
| // Create or link an experiment for this backtest | ||
| const exp = await leanApi.createExperiment({ | ||
| strategyId: result.request.strategyId || result.request.strategyName, | ||
| hypothesis: `Research integrity evaluation for ${result.request.strategyName} (${result.request.symbol})`, | ||
| parameters: result.request.parameters || {}, | ||
| inSamplePeriod: { | ||
| start: result.request.startDate, | ||
| end: result.request.endDate | ||
| }, | ||
| instruments: [result.request.symbol] | ||
| }) | ||
|
|
||
| if (exp?.experiment?.id) { | ||
| openOrFocus({ | ||
| kind: 'quant-lab-integrity', | ||
| params: { experimentId: exp.experiment.id } | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Completes the LEAN/QuantConnect integration on
feat/lean-integration(rebased onto currentdev, +13 commits) after a full Codex session that ended mid-verification. Two batches:1. Managed backtests now execute through the native
leanCLILeanService.runBacktestscaffolds a per-run project (lean.json+ algorithm) underdata/lean/runs/<id>/projectand invokeslean backtest . --output <results>when the CLI is installed; the existing Docker runner remains the automatic fallback for CLI-less environments.totalPerformance.{trade,portfolio}Statistics, ordersymbol.value) with full backward compatibility for the classic PascalCase shape; the summaryStatisticsdict is merged over the full result so orders/charts/stats all parse.completedwith a data-quality note instead offailed.quant-labskill documents the executor.2. Native LEAN CLI surface + LEAN GUI rename (from the Codex session)
checkLeanCli()probe →/api/lean/config,/api/lean/status(leanCliAvailable/Version/Error); newleanStatustool backsalice-quant system status.leanCLI next toalice-quant;quant-labskill bundled for every tool-bearing workspace (context injector).quant-labroute IDs intact.alice-quant --help) describe the renamed surface.Verification
npx tsc --noEmit✓ ·cd ui && npx tsc -b✓ · fullpnpm test: 5334 passed / 0 failed ✓quantconnect/lean:latest,lean1.0.229):summary.json✓Environment notes
data/lean+~/.lean/tmpare labeledcontainer_file_tvia semanage fcontext on this machine.agent-probe.spec.tsfails whenANTHROPIC_API_KEY/ANTHROPIC_BASE_URLare set in the ambient environment (SDK env leak); passes with them unset. Pre-existing, unrelated to LEAN (also seen in the earlier session).