Inspiration Options markets are fast-moving and data-dense. Traders juggle multiple screens of greeks, volatility surfaces, and news feeds — all while trying to spot fleeting mispricing windows. I asked: what if you could just talk or chat to an AI analyst that watches the market for you, explains what it sees, and generates charts on demand — and also texts you on Whatsapp when it spots an opportunity? The Gemini Live API's native audio streaming, combined with OpenClaw's scheduling and messaging engine, made that vision real.
What it does VegaEdge is a full-stack options trading platform with a Gemini-powered voice and chat AI agent at its core. The agent:
- Speaks and listens in real time using Gemini's native audio model (
gemini-2.5-flash-native-audio-preview) over a WebSocket bridge, with live transcription of both user speech and agent responses. - Calls 4 specialized tools grounded in real market data from Alpaca API:
analyze_ticker— runs IV vs HV volatility analysis on any stock using Alpaca real-time options data, returning a BUY/SELL/NEUTRAL signal with ATM option details.scan_watchlist— scans 5 tickers simultaneously (HOOD, CIFR, WULF, PYPL, GRAB) and summarizes which have actionable signals.get_keltner_chart— generates a Keltner Channel chart (PNG) showing price position within volatility bands, streamed directly into the UI.get_signal_details— provides detailed signal breakdowns with opportunity sizing.
- Supports two modes: Voice mode (Gemini Live API with bidirectional audio) and Chat mode (Gemini 2.5 Flash with multi-turn tool calling).
- Automated WhatsApp Alerts via OpenClaw + Cron Jobs — OpenClaw runs 3 scheduled cron jobs (11 AM ET and 3 PM ET on weekdays) that trigger IV/HV analysis across the watchlist and deliver formatted buy/sell signals directly to WhatsApp via OpenClaw's
messagetool. Signal logic:- 🟢 BUY LEAP: IV/HV < 0.8 + Keltner BOTTOM — options are underpriced, ideal for buying long-dated calls
- 🔵 SELL CSP: IV/HV > 1.3 + Keltner BOTTOM — IV elevated, sell cash-secured puts to collect premium
- 🔴 SELL CALL: IV/HV > 1.3 + Keltner TOP — IV elevated and price overextended, sell covered calls
Beyond the agent, VegaEdge is a 16-page trading dashboard with 60+ API endpoints covering:
- Black-Scholes pricing engine with full Greeks (delta, gamma, theta, vega, rho, vanna, volga, charm)
- IV solver and 3D volatility surface visualization
- Walk-forward backtesting with Sharpe, Calmar, and max drawdown metrics
- Risk management with 3 VaR methods (Historical, Parametric, Monte Carlo)
- EV calculator and dynamic delta-gamma hedging
- Live Alpaca paper trading for stocks and options
- Autonomous mispricing scanner (auto-engine)
- NLP sentiment analysis on market news
- Trade journal with P&L tracking
- IV-based alerts dashboard — real-time summary of watchlist tickers showing IV/HV ratio, HV percentile, volume surge detection, and crash/rally signals with clear BUY/SELL recommendations
How I built it
Voice pipeline: Browser microphone audio is captured via an AudioWorklet processor at 16 kHz mono PCM, base64-encoded, and streamed over WebSocket to a FastAPI server. The server bridges this to the Gemini Live API using google-genai's client.aio.live.connect(). Gemini's audio responses stream back through the same WebSocket and are decoded and played at 24 kHz using the Web Audio API with queue-based scheduling.
Tool calling: When Gemini invokes a tool (e.g., analyze_ticker), the FastAPI server fetches real-time options data from the Alpaca API — including IV, Greeks, bid/ask, and HV percentiles — packages the result, and sends a function_response back to Gemini, which then narrates the findings to the user.
Chat mode: Uses gemini-2.5-flash with generate_content() in a tool loop (up to 10 rounds), maintaining conversation history. Tool results (charts, signals, watchlist data) are streamed to the frontend as they're generated.
Trading engine: Python backend with modular architecture — pricing engine (Black-Scholes, Greeks, IV solver), data layer (Alpaca API for real-time options data, HMM regime detection), backtesting engine, strategy/hedging calculators, risk management (VaR), and Alpaca execution client.
OpenClaw Automation: OpenClaw acts as the scheduling and delivery layer. It runs 3 cron jobs — at 11 AM ET and 3 PM ET on weekdays — that call the VegaEdge IV analysis engine against the live Alpaca feed. OpenClaw then uses its built-in message tool to push the formatted alert to WhatsApp. The alert includes ticker, price, HV percentile, IV/HV ratio, and a specific strategy recommendation (BUY LEAP / SELL CSP / SELL CALL) based on the IV and Keltner Channel position.
Frontend: Next.js 16 with React 19, TypeScript, and Tailwind CSS. Dark-themed UI (#1E1E1E) with a custom useVegaEdgeSession hook managing WebSocket connections, audio capture/playback, and real-time state updates.
Deployment: Backend containerized with Docker and deployed to Google Cloud Run.
Challenges I ran into
- Audio latency: Getting smooth bidirectional audio required careful buffer management. The AudioWorklet runs on a separate thread, and I needed queue-based scheduling on playback to prevent audio chunks from overlapping or creating gaps.
- Tool call orchestration: In chat mode, Gemini sometimes chains multiple tool calls before responding. I implemented a loop that keeps calling
generate_content()until Gemini produces text, not just tool calls, while streaming intermediate results (charts, signals) to the UI in real time. - Real market data reliability: Alpaca API occasional rate limits and missing option chain data required defensive error handling across all 5 watchlist tickers without blocking the entire scan.
- Cron timing precision: Ensuring OpenClaw-triggered alerts fire exactly at market-relevant times (11 AM and 3 PM ET) and that Alpaca data is fresh at those moments required careful scheduling and cache-busting logic.
Accomplishments that we're proud of
- End-to-end voice interaction with a financial AI agent that calls real tools and returns real Alpaca market data — not a toy demo.
- Live transcription of both user speech and agent responses, so users can follow along visually while talking.
- Chart generation in-conversation — ask the agent for a Keltner chart and it appears in the sidebar while the agent explains what it shows.
- 16-page production dashboard with 60+ endpoints covering the full options trading workflow from analysis to execution.
- Seamless mode switching between voice and chat without losing conversation context.
- Fully automated WhatsApp alert pipeline — OpenClaw cron jobs deliver actionable IV/HV-based strategy signals (BUY LEAP, SELL CSP, SELL CALL, SELL PUT) straight to a trader's phone twice per trading day, with zero manual intervention.
What I learned
- The Gemini Live API's native audio model handles financial terminology (IV, HV, Greeks, ticker symbols) remarkably well with minimal prompt engineering.
- AudioWorklet is essential for low-latency audio capture — the older ScriptProcessorNode introduces noticeable delays.
- Grounding AI responses in real tool outputs (actual Alpaca market data, generated charts) dramatically improves trust and usefulness compared to pure language generation.
- OpenClaw's combination of cron scheduling and message delivery is a powerful pattern for passive market monitoring — the system works even when the user isn't actively watching the dashboard.
Built With
- alpacaapi
- audioworklet
- docker
- fastapi
- gemini
- geminiliveapi
- google-cloud
- matplotlib
- next.js
- openclaw
- python
- react
- tailwindcss
- typescript
- websocket
- yahoofinance
Log in or sign up for Devpost to join the conversation.