Vibe-Trading: Four Weeks of Architecture Evolution and Hardcore Quant Engineering
Over the past four weeks (early September to early October 2026), the open-source autonomous quantitative trading system Vibe-Trading underwent its most sweeping engineering leap since inception. From v0.1.15 ("*Data that says what it is*") to v0.1.16 ("*A number that can show where it came from*") and ongoing work on the main branch, the repository merged over 1,000+ commits, completing a systematic rework spanning anti-hallucination attribution, long-form research report resilience, mathematical foundations, a global multi-country data platform, and multi-broker asset management.
Key points
- Grounding Gate 2.0 (
agent/src/agent/grounding/): replaced fuzzy natural-language regex matching (65 regex rules) with morphology-based numeric classification plus a structuredfiguresdeclaration block (value | role | note | ref) with five roles:observed,derived,proposed,cited,count. Unverified numbers are now gracefully masked as(omitted※)instead of rejecting the whole report; correction rounds cut from 4 to 1. - Real context-window awareness & tiered compaction (
agent/src/agent/loop.py): dropped the crude 40k-token truncation that caused multi-ticker report dead loops (no_progressstalls). Now adapts to actual model windows (e.g., DeepSeek V4 1M, GPT-6 Sol 272K) and progressively prunes stale tool data at 80%/90%/100% thresholds. - Quant Library: 15 peer-reviewed models (
agent/src/quantlib/): Heston stochastic volatility pricing, Hierarchical Risk Parity (HRP), microstructure metrics (VPIN, Roll, Kyle's Lambda, Amihud), and Purged K-Fold cross-validation. - Alpha Zoo: 59 factors debugged (
agent/src/factors/): fixed suspension-gap arithmetic bias and NaN contagion; corrected the Carhart momentum skip-month rule (t-252 to t-21) to remove short-term reversal contamination. - Global market data: added UK (LSE) and Argentina (BYMA) markets; correct one-way SDRT stamp duty (0.5% buyer-only); weekly automated health probes of 15 unauthenticated data sources.
- Brokers & Portfolio v3: connector count grew to 18 (KIS, Upbit, Toss, Scalable, etc.); a "Red Line Policy" hard-blocks live order placement on brokers lacking sandbox isolation; multi-broker read-only aggregation with explicit errors on data-source anomalies (no "fake shrinkage" from stale caches).
- UI & architecture: Web UI manages DingTalk, WeCom, QQ, Feishu/Lark, Email, and WebSocket channels; MCP tool payloads de-duplicated (4x redundancy removed); main loop and tool parsing decoupled (
tool_results.py); localization added Indonesian and Brazilian Portuguese (9 languages total). - Morphology over semantics: numbers are judged by their form (percentages, currency symbols, decimals, table layout), not regex guesses.
- Structured
figuresblock: the model declares every figure at the end of its answer withvalue | role | note | ref: observed: must trace exactly to a tool output for the given ticker/field in the current session;derived: must carry a parseable arithmetic expression (ratios, multiples, percentage-point differences);proposed/cited/count: verified for order price ranges, external citations, and integer parameters respectively.- Cut rather than refuse: on verification failure, numbers are masked as
(omitted※)with a footnote instead of discarding the whole report; correction rounds reduced from 4 to 1. - Backtest self-verification: Run Cards and metric tables (Sortino, Turnover, Monte Carlo p-values) are injected into the evidence pool, eliminating fabricated backtest analysis.
- Real-time awareness of the underlying model's actual window; stale raw tool data is pruned bottom-up at 80%/90%/100% token consumption.
- Out-of-bounds file exploration returns a canonical root path instead of letting the model exhaustively probe non-existent directories.
- Heston (1993) stochastic volatility: CIR mean-reverting variance process, European option prices via characteristic-function inversion:
- Hierarchical Risk Parity (López de Prado, 2016): hierarchical clustering on the correlation matrix with recursive inverse-variance allocation, avoiding ill-conditioned covariance inversion.
- Microstructure: VPIN, Amihud (2002) illiquidity, Kyle (1985) Lambda, Roll (1984) effective spread:
- Purged K-Fold Cross-Validation (López de Prado, 2018): purging and embargo at train/test boundaries to eliminate lookahead bias.
- Carhart (1997) momentum correction:
academic_carhart_momnow strictly skips the most recent month (t-252 to t-21 trading days), never referencing today's close: - Fixed 24 factors producing false signals from comparison operators on suspension gaps, 20 factors padding suspension days with constants,
qlib158CNTP/CNTN/CNTD and WVMA numerator issues, andgtja191extreme-day ranking. - UK (LSE): full support for
.L/.ILtickers; precise SDRT modeling — 0.5% charged on the buyer only, halving previously overstated transaction costs. - Argentina (BYMA):
.BAstocks and CEDEARs in ARS, hard-isolated from USD asset pools. - Resampling engine: unified weekly (
1W) and monthly (1M) candle synthesis across data sources. - Reliability watchdog (
loader_health): weekly sandboxed probes against 15 unauthenticated public sources (Yahoo, Eastmoney, Tencent, BaoStock, etc.) with circuit-breaker alerts; A-share data classified assplit_dividend_additiveadjustment to prevent Sharpe distortion; 30-second timeout watchdog for BaoStock. - Red Line Policy: brokers without strict sandbox isolation or live-auth flags (e.g., Zerodha, Toss, Upbit) have live order placement hard-blocked at the code level — paper trading and read-only only.
- Capability matrix: README matrix generated from 55 Profile registries, validated in CI.
- Portfolio v3: cross-account aggregation with explicit, isolated errors on source failures — never falls back to stale caches.
- IM channel management: DingTalk, WeCom, QQ, Feishu/Lark, Email, and WebSocket configured via Web UI; secrets shown as last-four-only (
**1234) with live connectivity probing (no restart). - Email: RFC 2971 IMAP
IDhandshake added to pass Netease 163/126 security checks. - De-duplication & decoupling: MCP structured data previously passed to the agent 4 times redundantly — removed; large tool-dispatch functions split out of
loop.pyintotool_results.py. - Localization**: +Indonesian and Brazilian Portuguese (9 languages total).
1. Grounding & Long-Context Resilience
Financial agents' worst failures are fabricated metrics and hallucination. Previously, numeric meaning was guessed from surrounding natural-language vocabulary; long reports repeatedly refetched data due to context-budget overruns.
Grounding Gate 2.0
Tiered Context Compaction
2. Quant Library & Alpha Zoo
Derivatives pricing and allocation
Alpha Zoo fixes (59 factors)
3. Global Market Data Platform
4. Brokers & Portfolio v3
5. UI, IM Channels & Architecture
References
1. Carhart, M. M. (1997). On persistence in mutual fund performance. *The Journal of Finance*, 52(1), 57–82. 2. Heston, S. L. (1993). A closed-form solution for options with stochastic volatility with applications to bond and currency options. *The Review of Financial Studies*, 6(2), 327–343. 3. López de Prado, M. (2016). Building diversified portfolios that outperform out-of-sample. *The Journal of Portfolio Management*, 42(4), 59–69. 4. López de Prado, M. (2018). *Advances in Financial Machine Learning*. John Wiley & Sons. 5. Kyle, A. S. (1985). Continuous auctions and informed trader. *Econometrica*, 53(6), 1315–1335. 6. Amihud, Y. (2002). Illiquidity and stock returns: cross-section and time-series effects. *Journal of Financial Markets*, 5(1), 31–56. 7. Easley, D., López de Prado, M. M., & O'Hara, M. (2012). Flow toxicity and liquidity in a high-frequency world. *The Review of Financial Studies*, 25(5), 1457–1493. 8. Patell, J. M. (1976). Corporate forecasts of earnings per share and stock price behavior: Empirical tests. *Journal of Accounting Research*, 14(2), 246–276.