How lecoeurdelest/wqbr works
Purpose and Entry Points
This is a Python research platform centered on quantitative-alpha research. It provides a WorldQuant BRAIN compatibility toolkit plus a platform-neutral Research Center for future providers. Main runtime entry points are the WorldQuant MCP stdio server (wq_brain_mcp/__main__.py, wq_brain_mcp/server.py), central multi-platform MCP gateway (research_center_mcp/server.py), and WorldQuant ingest orchestration (research_platforms/worldquant/pipeline/run_all.py). Package commands are defined in pyproject.toml.
API Boundary and WorldQuant Binding
wqbrain is the provider-facing transport/client layer: it authenticates, retries, rate-limits, polls asynchronous BRAIN operations, validates responses, and decodes endpoint payloads. Its models separate API contracts from downstream logic. WorldQuant-specific behavior is contained in the binding rather than spread through core research components.
Paths: wqbrain/transport.py, wqbrain/client.py, research_platforms/worldquant/scorecard.py.
Local Lake and Ingest Pipeline
The lake is the durable system of record for remotely fetched data, avoiding repeated network reads and simulation quota consumption. The WorldQuant pipeline ingests catalog, alpha, check, and PnL domains; then transforms, quality-checks, materializes marts, and persists pipeline state. Storage uses Parquet and DuckDB-oriented views/layouts, with atomic/idempotent writes implied by the pipeline boundary.
Paths: wqbrain_lake/layout.py, wqbrain_lake/writer.py, research_platforms/worldquant/pipeline/run_all.py.
Canonical Multi-Platform Data Path
The newer center architecture defines platform-scoped domain data and an injected projection pipeline, currently delivered for daily performance. research_data owns canonical performance records/repository semantics; research_pipeline projects provider data into this representation; research_analytics consumes canonical data through its analytics port. Other WorldQuant data domains remain provider-specific/staged.
Paths: research_data/performance.py, research_pipeline/performance.py, research_analytics/performance.py.
Analytics, Portfolio, and Visualization
Offline analytics operates on local/canonical PnL to calculate metrics, correlations, attribution, scorecards, parameter sweeps, and region-aware shadow-book risk/performance. This boundary must not require BRAIN calls. Visualization turns analytics datasets into static images or self-contained offline HTML using matplotlib and Plotly.
Paths: research_analytics/metrics.py, research_analytics/portfolio.py, wqbrain_viz/report.py.
Research Center, Policy, and Memory
The Research Center is the platform-neutral control plane: registry/capability routing, actor policy, research submissions, event capture, outcome memory, and cited knowledge. Research gates evaluate expression and lineage requirements before simulation budget reservation. Policy separates human and AI modes; AI routes cannot invoke irreversible submission capability or self-approve AI-originated knowledge.
Paths: research_center/processor.py, research_center/memory.py, wqbrain_research/gates.py.
MCP Interfaces and Safety Boundaries
Two stdio MCP servers expose the system to LLM clients: a WorldQuant-compatible façade and a central gateway. Read tools favor lake-first access; simulation returns local job UUIDs rather than remote progress handles. Submission is opt-in, requires a human mode, explicit confirmation, and passing checks. Config is non-secret TOML with environment credential/override support.
Paths: wq_brain_mcp/server.py, wq_brain_mcp/tools/simulate.py, research_center_mcp/server.py.
Main entry points: processor.py Research processor · client.py BRAIN client · server.py WorldQuant MCP server · run_all.py WorldQuant ingest
Components 17
MCP Interfaces
- WorldQuant MCP server · Compatibility tools with lake-first reads and guarded submission.
wq_brain_mcp/server.py - Simulation tool · Returns local job UUIDs rather than remote progress handles.
wq_brain_mcp/tools/simulate.py - Research Center MCP · Platform-neutral gateway for multi-provider research.
research_center_mcp/server.py
WorldQuant Integration
- BRAIN client · Authentication, retries, rate limits, polling, validation, and payload decoding.
wqbrain/client.py - HTTP transport
wqbrain/transport.py - WorldQuant ingest · Ingests catalog, alpha, check, and PnL domains.
research_platforms/worldquant/pipeline/run_all.py - WorldQuant scorecards
research_platforms/worldquant/scorecard.py
Data & Analytics
- Lake layout · Parquet and DuckDB-oriented durable local record.
wqbrain_lake/layout.py - Lake writer · Idempotently materializes staged lake data and state.
wqbrain_lake/writer.py - Canonical performance · Platform-scoped performance records and repository semantics.
research_data/performance.py - Performance projection · Projects provider performance into the canonical representation.
research_pipeline/performance.py - Offline analytics · Computes metrics, correlations, attribution, and portfolio analysis without BRAIN calls.
research_analytics/metrics.py - Shadow-book portfolio · Region-aware risk and performance analysis.
research_analytics/portfolio.py - Offline reports · Creates static images and self-contained HTML reports.
wqbrain_viz/report.py
Research Center
- Research processor · Routes capabilities, processes submissions, and captures research events.
research_center/processor.py - Outcome memory · Stores outcomes and cited research knowledge.
research_center/memory.py - Research gates · Checks expression and lineage before simulation budget reservation.
wqbrain_research/gates.py
Connections 19
- WorldQuant MCP server → Simulation tool: exposes
- Simulation tool → Research gates: checks before reservation
- WorldQuant MCP server → Lake layout: reads lake first
- WorldQuant MCP server → BRAIN client: provider operations
- BRAIN client → HTTP transport: uses
- WorldQuant ingest → BRAIN client: fetches remote domains
- WorldQuant ingest → Lake writer: persists staged data
- Lake writer → Lake layout: writes Parquet and views
- WorldQuant ingest → WorldQuant scorecards: materializes
- Performance projection → Canonical performance: projects into
- Lake layout → Performance projection: provider performance input
- Canonical performance → Offline analytics: canonical analytics input
- Offline analytics → Shadow-book portfolio: supplies metrics
- Offline analytics → Offline reports: report datasets
- Research Center MCP → Research processor: routes requests
- Research processor → Research gates: enforces policy and gates
- Research processor → Outcome memory: captures outcomes
- Research processor → Performance projection: invokes projection
- Research gates → BRAIN client: permits guarded simulation