Skip to content

SamarFatimaJaffri/Stock-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Stock Analyzer

StockAnalyzer is an AI-powered stock analysis assistant that provides real-time stock data, historical prices, financial statements, and news regarding public companies.

Features

  • Real-time Stock Prices: Get current market prices
  • Historical Data: Analyze price trends over custom date ranges
  • Latest News: Stay updated with company-specific news
  • Balance Sheets: Access detailed financial statements
  • Conversational Interface: Natural language queries powered by GPT-5
  • Streaming Responses: Real-time AI responses
  • Conversation Memory: Maintains context across chat sessions

Tech Stack

Backend:

  • FastAPI → Modern web framework for building APIs
  • LangChain → Framework for building LLM applications
  • LangGraph → Stateful agent orchestration
  • yfinance → Yahoo Finance data retrieval
  • OpenAI (via Thesys API) → Gen AI model

Frontend:

  • React/Vite

Project Structure

stock-analyzer/
├── backend/
│   ├── main.py          # FastAPI app, and routes
│   ├── app/
│   │   ├── agent.py        # Agent that stock market data for you
│   │   ├── schemas.py      # Pydantic request models
│   │   └── tools.py        # Stock-related LangChain tools
│   ├── requirements.txt
│   ├── .env.example
│   └── .env             # Environment variables (not committed)
├── frontend/
│   ├── src/
│   │   ├── assets/
│   │   │   └── ...
│   │   ├── App.tsx         # Connext frontend to backend API
│   │   └── ...
│   └── ...              # Default Frontend files
├── .gitignore
└── README.md

Installation

Prerequisites

  • Python 3.13
  • Node.js 24.13 (for frontend)
  • Thesys API account

Backend Setup

  1. Create a virtual environment
   python -m venv venv
   source venv\Scripts\activate  # On Linux: venv/bin/activate
  1. Install Python dependencies
   pip install -r backend\requirements.txt
  1. Configure API Key
    • Sign up at Thesys
    • Generate your API key from the dashboard
    • Create a .env file in the backend directory:
     THESYS_API_KEY=<API-KEY-HERE>

Frontend Setup

  1. Navigate to frontend directory
   cd frontend
  1. Install dependencies
   npm install

Running the Application

Start the Backend

# From the project root
python -m uvicorn backend.main:app --reload

The API will be available at http://localhost:8000

Start the Frontend

# From the frontend directory
npm run dev

The frontend will be available at http://localhost:3000 (or your configured port)

Available Tools

The agent has access to the following tools:

  1. get_stock_price - Fetches current stock price

    • Input: ticker symbol (e.g., "AAPL")
  2. get_historical_stock_price - Retrieves historical price data

    • Input: ticker, start_date, end_date (format: YYYY-MM-DD)
  3. get_balance_sheet - Gets company balance sheet

    • Input: ticker symbol
  4. get_stock_news - Fetches latest company news

    • Input: ticker symbol

Example Queries

  • "What's the current price of Tesla?"
  • "Show me Apple's stock performance from January 2024 to March 2024"
  • "Get the balance sheet for Microsoft"
  • "What's the latest news about NVIDIA?"
  • "Compare the prices of GOOGL and META over the last month"

Troubleshooting

Windows: File Access Issues

If you encounter file access errors when running the application on Windows, this is likely due to permission restrictions in PowerShell.

Solution: Try running the application from Command Prompt (cmd) instead of PowerShell to resolve the error.

Disclaimer

This tool is for informational purposes only. Not financial advice. Always do your own research before making investment decisions.

About

Stock Analysis agent powered by OpenAI, LangChain, Thesys, and Yahoo Finance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors