AI Stock Agent
I've been developing Stock Agent — an AI-driven personal tool that analyzes live market data, technical indicators, macro factors like yield curves and Fed policy probabilities, bond volatility, treasury auction results, and fresh economic/news feeds to generate clear trading recommendations: BUY, HOLD, SELL, or SHORT, complete with suggested entry levels, targets, stops, conviction, catalysts, risks, and position sizing ideas.
When you have open positions (long or short), it tracks them, calculates real P&L, and factors your current exposure plus recent signal history into every new recommendation — so the advice stays personalized and contextual rather than generic.
Core Features
- Structured Output: The AI always ends with a clean, parseable block including SIGNAL, TIMEFRAME, ENTRY_PRICE, TARGET_PRICE, STOP_PRICE, CONVICTION, PRIMARY CATALYST, PRIMARY RISK, POSITION_SIZING, and (if relevant) POSITION_RECOMMENDATION or OPTION_RECOMMENDATION.
- Trade Tracking: Log your actual trades (direction, date, price, quantity); see unrealized/realized P&L; view positions on charts with entry/exit markers.
- Analysis History: Saves each run as JSON; review past signals; auto-scores accuracy (win rate, avg reward:risk) by comparing old BUY/SHORT calls to later price action.
- UI & Workflow: Streamlit app shows candlestick charts (with swing high/low markers, signal overlays, position diamonds), live streaming text output, tool progress logs, metrics dashboard, and easy trade entry/closure.
- CLI Option: Quick terminal queries like python agent.py "What's the setup given current macro conditions?"
Tech & Architecture Highlights
Powered by Claude Opus 4.6 (strong reasoning for multi-source financial analysis).
- Cost optimizations: Prompt caching on the system prompt, no extra internal thinking steps — keeps runs affordable (~$0.60–0.90 each).
- Tools (exposed to the model): Market data & technicals (RSI, MACD, Bollinger, MAs), treasury yields & real yields, Fed cut/hike probabilities from futures, bond MOVE index, recent auction metrics, options chain data, plus server-side web search for breaking news (CPI, jobs, Fed commentary).
- Analysis order is enforced: macro regime → yield drivers → technicals/options.
Why Build This?
I wanted full transparency to see exactly what data feeds in, how the reasoning flows, and why a signal is generated. No black-box alerts — just a tool that evolves with your real positions and learns from past performance via the history scorecard.
Code lives locally for now (happy to discuss architecture or share snippets if you're building similar agentic tools). Future ideas include backtesting past signals, price alerts, notifications, and expanding macro tools to other rate-sensitive assets.
If you're experimenting with AI for trading or macro analysis, I'd love to hear your thoughts — drop a note!