Vibe-Trading Biweekly Fix Log: Exorcising Bugs from Matching, Factors, and Risk Control
> Review period: 2026-08-24 to 2026-09-07. A digest of merged PRs in the open-source Vibe-Trading automated trading project — no grand roadmap talk, just hardening patches.
Key points
- Gold order truncated to zero (#1370): cross-asset backtests applied forex micro-lot rounding to a 50 oz XAU/USD order, wiping it to 0 lots. Multi-asset measurement is now fully decoupled.
- Futures multiplier bug (#1369): prefixed symbols (e.g.,
6EZ4,M2K) fell back to a default multiplier of 50 instead of the true 125,000 for Euro FX futures — understating exposure by ~2,500x. Fixed via longest-prefix-tree lookup. - 82 factors patched for NaN signals (#1371–#1376): Python ternaries like
signal = 1 if (rolling_delta > 0) else -1evaluatedNaN > 0asFalse, emitting constant-1(strong short) fake signals during warm-up/suspensions. All 82 factors now use strict NaN guards with forward propagation. - Suspension-day handling (#1332): close prices on halted days were being reset to cost basis; replaced with forward-fill of fair value.
- Limit-order margin check (#1361): capital verification now uses the worst side:
max(P_limit, P_market) × qty × (1 + slippage buffer). - Fail-Closed audits (#1362): a zero verification-point audit log previously passed; now treated as a top-severity violation.
- Kill-Switch double-liquidation fix (#1233, #1244): after a full liquidation, a service restart could lose in-memory state and open an opposite market order. A disk sentinel file now locks positions until manually unlocked.
- India — Zerodha Kite Connect (#1193): NSE/BSE market data plus simulated live matching.
- London — LSE penny-stock trap (#1206): GBX quotes vs GBP settlement now auto-converted:
GBP = GBX × shares / 100. - Iran — Nobitex/Wallex (#1231, #1263): Toman-denominated crypto pairs, with drag-and-drop prioritization across 27 auto-rotating data sources.
- Anthropic prompt caching (#1366): static tool schemas and system prompts are cached — ~75% token cost reduction and roughly half the latency.
- 8-round circuit breaker (#1363): identical tool parameters failing twice are rejected; 8 consecutive non-productive rounds trigger a hard stop and human alert.
- Language-agnostic market-closed checks (#1349): the Chinese "市场已休市" string bypassed the English regex; validation moved to a language-independent state machine.
- Heston (1993) stochastic volatility option pricing — variance follows a mean-reverting process with price-volatility correlation ρ, capturing the volatility smile.
- Hierarchical Risk Parity (HRP) — replaces ill-conditioned covariance inversion with tree clustering on correlation distance
D = sqrt((1 - ρ)/2). - VPIN order-flow toxicity — volume-bucketed buy/sell imbalance as an early-warning signal for flash crashes; market makers withdraw above threshold.
Global market expansion
Agent guardrails
Quant math upgrades (#1195–#1198, #1203)
Closing assessment
| Dimension | Before (~08-24) | After (09-07) | Verdict | | :--- | :--- | :--- | :--- | | Backtest fidelity | Shrunk futures, halted-day gaps, zeroed gold | Strict adjustment, decoupled units | Squeezed dry | | Factor reliability | Missing data leaking as ±1 signals | Strict NaN guards on 82 factors | Clean signals | | Live safety | Restart could flip liquidation into a naked short | Disk sentinel + pessimistic margin checks | Solid wall | | Agent stability | Error loops, inflated token spend | Prompt cache + 8-round breaker | Reined in | | Math depth | Moving averages, static Black-Scholes | Heston, HRP, VPIN | Modernized |
A real trading system isn't proven by returns quoted in calm waters, but by code that survives the storm.