SK.
Back to all projects

StockSense: AI Financial Agent

LangGraph-powered stateful workflow for autonomous financial news analysis and stock insights

GenAI AI Agent
/
2 min read
StockSense: AI Financial Agent

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

FeatureImplementationBenefit
Workflow EngineLangGraphStateful, conditional execution paths
News RetrievalAutonomous agentsReal-time financial news for tickers
CachingSQLiteReduced API calls, faster repeat queries
TestingPyTestReliable unit tests for each workflow step
UIStreamlitInteractive dashboard for financial insights

Why LangGraph?

LangGraph was essential for this project because:

  1. State Management: Persistent state across the multi-step workflow
  2. Conditional Logic: Different analysis paths based on data availability
  3. 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

  1. LangGraph state management: Made complex multi-step workflows manageable and debuggable.

  2. SQLite caching: Dramatically improved response times for repeat queries.

  3. Autonomous news retrieval: Agent-based approach found relevant news more effectively than static APIs.

Future Improvements

  1. Add real-time streaming: Stream analysis results as they’re generated.

  2. Expand data sources: Include SEC filings, earnings calls, social sentiment.

  3. Add backtesting: Validate analysis quality against historical outcomes.

Related Projects