English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Vibe-Trading Biweekly Bug Purge: Wrong Gold Lot Sizes, Fake Alpha Signals, and Fail-Closed Risk Controls

Forum topic · 小凯 · 2026-09-07

Summary

This forum post reviews two weeks of engineering work (August 24 to September 7, 2026) on the open-source Vibe-Trading quantitative trading project, focusing on correctness and safety fixes rather than new features. Key fixes include: a multi-asset unit bug that rounded a 50-ounce XAU/USD gold order to zero lots (#1370); a futures multiplier parsing flaw that fell back to a default multiplier of 50 instead of 125,000 for contracts like 6EZ4, understating exposure by up to 2,500x (#1369); and NaN-corrupted ternary logic that turned missing data in 82 Alpha101/GTJA factors into false +/-1 short signals (#1371-#1376). Risk-control hardening adds pessimistic worst-case margin checks for limit orders (#1361), Fail-Closed auditing when verification counts are zero (#1362), and a disk-based sentinel lock preventing a Kill-Switch liquidation from becoming an accidental net short after restarts (#1233, #1244). Market coverage expands to India's Zerodha Kite (#1193), London Stock Exchange GBX-to-GBP conversion (#1206), and 27 rotating Iranian crypto data sources with Toman support (#1231, #1263). Agent reliability work adds Anthropic prompt caching (75% token savings, #1366), an 8-turn circuit breaker (#1363), and language-agnostic market-closed validation (#1349). The math library gains Heston stochastic volatility pricing, Hierarchical Risk Parity (HRP), and VPIN order-flow toxicity metrics (#1195-#1203).

A Chinese forum post documents two weeks (2026-08-24 to 2026-09-07) of hardening work on the open-source Vibe-Trading quantitative trading project. The theme: automated trading systems fail not because models predict poorly, but because low-level code keeps false books. Below is a full translation of the post's engineering review.

Key points

  • Gold orders silently rounded to zero: cross-market backtests applied forex micro-lot rounding rules to XAU/USD, wiping a 50-ounce gold position to 0 lots. Fixed by fully decoupling multi-asset unit models (#1370).
  • Futures multiplier fallback bug: contracts with numeric month prefixes (6EZ4, M2K) failed single-character matching and fell back to a default multiplier of 50 instead of 125,000 — understating real exposure by ~2,500x. Replaced with longest-prefix-tree lookup (#1369).
  • 82 Alpha factors poisoned by NaN: Python ternaries like signal = 1 if (rolling_delta > 0) else -1 evaluate NaN > 0 as False, emitting strong short (-1) fake signals during warm-up or suspension gaps. All 82 factors (Alpha101/GTJA) now use a strict NaN guard that propagates NaN instead of branching (#1371–#1376).
  • Suspension-day handling (#1332): suspended-day closes no longer reset to cost basis; fair values are forward-filled.
  • Risk-control hardening (Fail-Closed everywhere)

    1. Limit-order margin check (#1361): validation previously used the current market price, letting far-above-market limit buys pass only to blow margin at the exchange. Now uses pessimistic pricing: freeze max(P_limit, P_market) × qty × (1 + slippage buffer). 2. Auditor Fail-Closed (#1362): a zero verification count (parse timeout/malformed logs) used to PASS. Zero evidence now triggers a highest-severity violation and veto. 3. Kill-Switch double-liquidation guard (#1233, #1244): if the service restarts mid-liquidation, in-memory state loss caused the daemon to re-issue market sells — flipping a flat long account into a large naked short. A disk sentinel file now locks liquidation targets until a manual unlock.

    Global market expansion

  • India: Zerodha Kite Connect (#1193) — full NSE/BSE market data plus paper-trading execution.
  • LSE penny-stock trap (#1206) — GBX quotes settled as GBP caused ~100x account misvaluation; automatic GBP = GBX × shares / 100 conversion added.
  • Iranian exchanges (#1231, #1263) — Nobitex and Wallex with Toman pairs, plus a UI for rotating priority across 27 data sources with automatic failover on rate limits or outages.
  • Agent reliability and cost

  • Anthropic Prompt Caching (#1366): static tool schemas and rules are cached — ~75% token cost reduction and nearly half the latency.
  • 8-turn circuit breaker (#1363): identical tool errors are rejected on the 2nd attempt; 8 consecutive no-progress rounds trip a hard breaker and page a human.
  • Language-agnostic market-closed checks (#1349): English "Market Closed" blocked orders, but the Chinese equivalent leaked through a regex; replaced with a locale-independent state-machine check.
  • Quant math upgrades (#1195–#1198, #1203)

  • Heston (1993) stochastic volatility option pricing with mean-reverting variance and price–volatility correlation ρ, capturing the volatility smile.
  • Hierarchical Risk Parity (HRP) — cluster-based allocation avoiding ill-conditioned covariance inversion.
  • VPIN volume-bucket order-flow toxicity metric as a flash-crash early warning for market-making strategies.

Closing assessment

| Dimension | Before (~08.24) | After (09.07) | | :--- | :--- | :--- | | Backtest fidelity | shrunken futures, suspension gaps, gold zeroed out | strict adjustment, decoupled units | | Factor credibility | NaN leaking through ternaries | strict NaN guards on 82 factors | | Live-trading safety | restart could flip liquidation to short | disk sentinel + worst-case margin check | | Agent stability | error loops, inflated tokens | prompt cache + 8-turn breaker | | Math depth | moving averages, static Black-Scholes | Heston, HRP, VPIN |

The author's conclusion: a real trading system is proven not by returns quoted in calm markets, but by code that survives the storm.

Tags

#vibe-trading#quantitative-trading#backtesting#risk-control#nan-handling#fail-closed#llm-agents#heston-model

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178634597