.png&w=828&q=75)
AlphaGuard AI is an institutional-grade, risk-first autonomous trading desk designed to address the critical vulnerability in automated retail trading: undisciplined risk management. Powered by Gemini 2.5 Flash for sub-second market reasoning and seamlessly integrated with Alpaca's Paper Trading API, AlphaGuard decomposes trading operations into a specialized four-agent modular pipeline: 1. Market Sentinel Agent: Scans real-time price feeds, volume spikes, and technical patterns. 2. Strategy & Setup Agent: Formulates structured trade setups with precise entries, targets, and invalidation points. 3. Risk Officer Agent (Gatekeeper): Mathematically evaluates overall portfolio drawdown, enforces maximum 1% account risk per trade, and dynamically sizes positions. No order proceeds without its strict validation. 4. Alpaca Execution Agent: Dispatches approved, risk-cleared orders directly into the Alpaca paper execution engine. By establishing strict modular verification prior to execution, AlphaGuard AI bridges the gap between intelligent AI generation and institutional capital preservation.
4 Sep 2026
.png&w=828&q=75)
### 💡 Project Overview The Hybrid Token-Efficient Routing Agent is an advanced, production-ready backend solution engineered to tackle the challenges of modern LLM deployment: escalating cloud API costs and heavy token usage. Built using FastAPI, this smart routing engine dynamically evaluates incoming user requests and automatically decides the most cost-effective and accurate path for execution. ### ⚙️ How It Works & Architecture Our core routing engine implements a dual-layer intelligence system: 1. **Local Edge Processing (Ollama):** Simple, repetitive, or conversational prompts are automatically routed to a local Ollama instance running `llama3`. This processes requests entirely on local infrastructure, reducing external token dependency to zero. 2. **Cloud Intelligence Layer (Google Gemini 2.5 Flash):** When complex reasoning, multi-turn logic, or coding tasks are detected, the system immediately upgrades the workflow to Google Gemini 2.5 Flash. Gemini's high context window and lightning-fast processing power ensure precise execution for high-priority tasks. ### 🛡️ Failover & Resilience Mechanism One of the key innovations of this project is its robust error handling and failover resiliency. If the local Ollama server drops offline, runs out of memory, or returns an insufficient/short response, the architecture instantly captures the exception. Instead of breaking the user experience, it triggers an automated failover that routes the query straight to Gemini 2.5 Flash, guaranteeing a 100% uptime SLA. ### 🛠️ Technical Implementation * **Backend Framework:** FastAPI (Fully asynchronous implementation) * **Asynchronous Networking:** HTTPX for high-performance non-blocking API calls. * **LLM Models Integration:** Google Gemini 2.5 Flash (via official generative language APIs) and Ollama (`llama3`). * **Environment Architecture:** Configured seamlessly with custom router logic and dynamic environment variable extraction.
13 Jul 2026