Hedgify is an autonomous, multi-agent portfolio insurance system built for the Alpaca AI Trading Agents Hackathon (lablab.ai). It solves a problem every equity investor knows intimately: the panic-sell. When markets crash, retail investors liquidate their holdings to stop the bleeding — crystallizing losses, triggering tax events, and inevitably missing the rebound. Hedgify replaces that reflex with insurance: instead of selling your stocks when danger approaches, the system automatically buys protective put options — capping your downside while you keep every single share and ride the recovery. The system is architected as a Supervisor–Worker multi-agent pipeline. The Monitor Agent polls live portfolio data from Alpaca's paper trading API, tracks the all-time peak value, and computes real-time drawdown the moment any poll lands. When the drawdown crosses its threshold, the Monitor persists a snapshot, fires a structured alert into the database, broadcasts it over WebSocket to any connected dashboards, and hands off to the Hedge Executor Agent. The Executor then runs its gauntlet: an idempotency guard first checks whether the symbol already carries active protection (sixteen duplicate alerts become exactly zero duplicate orders); the live kill-switch is consulted, letting an operator disable autonomous trading mid-crisis without restarting anything; then the agent queries Alpaca's live options chain over its dedicated data API, matches the target strike (5% out-of-the-money by default) to the closest actually listed contract, validates expiry against the settings table, checks the premium against the configured budget, and places a real order through Alpaca's trading API — then polls asynchronously for the actual fill price, recording genuine market premiums rather than estimates.
Category tags: