How HedgeVision works — end to end.
Five complete workflow walkthroughs. Step-by-step. Full transparency into every decision the platform makes on your behalf.
The Complete Signal Lifecycle
From market data to filled order in under 60 seconds.
Signal Flow — APScheduler → Engine → LangGraph → Broker
LangGraph Deliberation
How HedgeVision debates a trade.
research_agentPerplexity is chosen for real-time web access. The narrative contains current market conditions, recent news, and relevant context that grounds the debate.
debate_agentThree simultaneous LLM calls in parallel — Bull, Bear, and Neutral. dissent_score is computed from the disagreement. 0.0 means unanimous consensus; 1.0 means maximum disagreement across agents.
deep_researchTriggered when dissent > 0.7. Maximum 3 loops. The ResearchService performs a focused deep dive on the specific hypothesis causing disagreement, then injects findings back into the debate.
allocator_agentKelly Criterion computes optimal position size. Four constraints are applied: correlation check, volatility targeting, sector limits, and ATR-based stops. Any constraint breach rejects the allocation.
red_team_nodeAn adversarial LLM (GPT-3.5-turbo chosen for instruction-following, not creativity). Its explicit job is to find every reason NOT to take the trade. kill_reason is a human-readable explanation.
sanity_guard_nodeThe 5% price check compares LLM-cited prices against live market data. Hallucination detection catches contradictions with TimescaleDB records. Any failure is an unconditional veto.
execution_agentGenerates the IC-level deal memo with 10 sections. Includes debate summary, risk metrics, hedge recommendations. Routes through DecisionGateway for approval tier determination.
LangGraph StateGraph — Deliberation Flow
Risk Pipeline
How HedgeVision protects capital — 8 stages, any can veto.
Runs before LLM deliberation (fast pre-check). Checks order book imbalance and wall detection. A hostile order wall can veto before any expensive model computation.
95th-percentile Conditional Value-at-Risk. Vetoes if the proposed position would breach portfolio risk budget or per-asset limits (5% max).
Kelly Criterion sizing with half-Kelly in production. Four constraints: correlation cap, sector limits, volatility targeting, ATR stops. Each can independently reject.
Monte Carlo simulation with jump-diffusion model. Not just historical stress — generates thousands of synthetic scenarios including fat-tailed jumps and crisis correlation spikes.
Applies four calibrated historical shocks: 2008 Financial Crisis, 2020 COVID Crash, 1987 Black Monday, 2010 Flash Crash. Position must survive all four.
Recommends protective instruments using Black-Scholes pricing. Advisory only — does not veto. Outputs are attached to the deal memo for human review.
A real adversarial LLM call, not a rules lookup. GPT-3.5-turbo is prompted to find every reason the trade should NOT be taken. Can veto with kill_reason.
Detects LLM hallucination by comparing cited prices to live data. A > 5% deviation is an unconditional veto. Also checks liquidity and structural consistency.
Risk Chain — 8-Stage Sequential Veto Pipeline
All veto decisions are stored in TimescaleDB for audit. The veto_stage and veto_reason fields provide complete traceability of why any trade was blocked.
Data Pipeline
Where the data comes from and how it gets clean.
Ingestion Tiers
Binance WebSocket streaming with 5-minute candle assembly. CCXT handles connection management, rate limiting, and auto-reconnection. Highest priority — crypto markets are 24/7.
FRED API and yfinance are combined for macro indicators (DGS10, VIX, DXY) and equity OHLCV. Hourly refresh aligned with market hours.
On-demand backfill triggered by DataContinuityModule when gaps are detected. Can backfill up to 5 years of historical data for new tickers.
Quality Gate — 5 Checks
TimescaleDB
Hypertable with 7-day chunk intervals. Compression after 7 days. 3-year retention. Continuous aggregates for hourly/daily/weekly rollups. 35,000+ chunks under management.
Redis
1GB LRU cache with allkeys-lru eviction. Key patterns: market:{ticker}:latest (1hr TTL), sentiment:{ticker} (1hr TTL), whale:{ticker} (2hr TTL), regime:current (30min TTL). Pub/sub for cross-module events.
Data Pipeline — Sources → Quality Gate → TimescaleDB → Redis
Execution & Broker Routing
How a trade order is placed, tracked, and confirmed.
Asset Class Routing
| Asset Class | Broker | Protocol |
|---|---|---|
| EQUITY | IBKR | ib-insync TWS |
| OPTIONS | IBKR | ib-insync TWS |
| FUTURES | IBKR | ib-insync TWS |
| FX | IC Markets MT4 | REST bridge :8005 |
| CRYPTO | Binance | CCXT REST |
| FALLBACK | Paper | Simulated fills |
Order Lifecycle
NAV Arbitrage Execution
For cross-broker arbitrage (e.g., SPY ETF vs ES futures, or BTC spot vs BTCUSDT perp):
- Entry: asyncio.gather(leg1, leg2) for simultaneous execution
- Entry trigger: |Z-score| > 2.0
- Exit trigger: |Z-score| < 0.3 (mean reversion)
Exchange Mapper
Internal tickers are translated to broker-specific symbols. BTC-USD becomes BTC/USDT on Binance. AAPL becomes AAPL STK SMART on IBKR. EURUSD=X becomes EURUSD on MT4.
Execution Routing — BrokerRouter → Adapters → Fill Confirmation