StockSense: AI Financial Agent
LangGraph-powered stateful workflow for autonomous financial news analysis and stock insights
The Problem
Financial analysis requires synthesizing multiple data sourcesβnews, market data, sentimentβinto actionable insights. Doing this manually is time-consuming and prone to bias.
The goal: Build an AI agent that autonomously collects, analyzes, and summarizes financial data for specific stock tickers.
Technical Implementation
Architecture: Stateful Multi-Step Workflow
Designed a stateful, multi-step workflow using LangGraph to orchestrate the analysis pipeline:
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β Data Collection ββββββΆβ Analysis ββββββΆβ Summarization β
β (News Retrieval)β β (Sentiment + β β (Final Report) β
β β β Fundamentals) β β β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
Key Technical Implementations
| Feature | Implementation | Benefit |
|---|---|---|
| Workflow Engine | LangGraph | Stateful, conditional execution paths |
| News Retrieval | Autonomous agents | Real-time financial news for tickers |
| Caching | SQLite | Reduced API calls, faster repeat queries |
| Testing | PyTest | Reliable unit tests for each workflow step |
| UI | Streamlit | Interactive dashboard for financial insights |
Why LangGraph?
LangGraph was essential for this project because:
- State Management: Persistent state across the multi-step workflow
- Conditional Logic: Different analysis paths based on data availability
- Controllable Flow: Clear orchestration of Data Collection β Analysis β Summarization
Tech Stack Breakdown
- Backend: FastAPI for API endpoints
- AI Orchestration: LangGraph for workflow management
- LLM: Gemini API for analysis and summarization
- Frontend: Streamlit for interactive UI
- Data Layer: SQLite for caching and persistence
- Testing: PyTest for unit and integration tests
What I Learned
What Worked Well
-
LangGraph state management: Made complex multi-step workflows manageable and debuggable.
-
SQLite caching: Dramatically improved response times for repeat queries.
-
Autonomous news retrieval: Agent-based approach found relevant news more effectively than static APIs.
Future Improvements
-
Add real-time streaming: Stream analysis results as theyβre generated.
-
Expand data sources: Include SEC filings, earnings calls, social sentiment.
-
Add backtesting: Validate analysis quality against historical outcomes.