
Explainable AI Trading Agent is a transparent, beginner-friendly trading assistant built on Alpaca's Trading API. Rather than acting as a black-box system, it combines classic technical analysis with AI-generated reasoning so users always understand why a trade decision was made. The agent fetches historical stock price data through Alpaca's Market Data API and applies a Moving Average Crossover strategy (5-day vs 20-day) to generate BUY, SELL, or HOLD signals. Once a signal is generated, Google's Gemini model produces a plain-language explanation of the underlying market logic — describing the trend, the moving average relationship, and what it means for a beginner investor. When a BUY or SELL signal is triggered, the agent automatically places a simulated trade using Alpaca's Paper Trading environment, ensuring zero financial risk while still demonstrating full end-to-end automation. A simple command-line interface lets users enter any stock symbol and instantly see the signal, its AI-generated explanation, and the resulting trade action. This project demonstrates how explainability can be layered onto algorithmic trading systems, making AI-driven finance tools more trustworthy and accessible to non-expert investors.
4 Sep 2026

This project solves a common problem in production AI systems: using an expensive large language model for every query, even simple ones, wastes both money and compute. The Token-Efficient Routing Agent addresses this by analyzing each incoming query and automatically routing it to the most appropriate model. Simple, direct questions (e.g., "What is the capital of France?") are routed to gpt-oss-20b, a smaller and faster model. Complex questions that require reasoning, comparison, or detailed explanation (e.g., "Explain how neural networks work in detail") are routed to gpt-oss-120b, a larger and more capable model. The routing decision is based on query length and the presence of complexity-indicating keywords such as "explain," "analyze," and "compare." After each response, the agent reports the tokens used, estimated cost, and estimated savings compared to always using the large model. This approach mirrors how production AI systems can meaningfully reduce inference costs at scale without sacrificing response quality where it actually matters, making it a practical and beginner-friendly introduction to cost-aware AI system design.
13 Jul 2026