Skip to content

StockGPT is a Flask-based web application that scrapes real-time stock data, performs fundamental and technical analysis, and generates professional investment reports using GPT-4. It supports advanced valuation models such as DCF, PE, Book Value, and Dividend Discount, with visual fair value comparisons and markdown-to-HTML reporting.

License

Notifications You must be signed in to change notification settings

ESJavadex/stockgpt

Repository files navigation

📊 StockGPT – Advanced Stock Analysis & Valuation App

StockGPT is a Flask-based web application that scrapes real-time stock data, performs fundamental and technical analysis, and generates professional investment reports using GPT-4. It supports advanced valuation models such as DCF, PE, Book Value, and Dividend Discount, with visual fair value comparisons and markdown-to-HTML reporting.


🚀 Features

  • 🔍 Scrapes technical & performance data from Barchart.com
  • 📈 Retrieves stock financials using Yahoo Finance API (yfinance)
  • 🧠 Generates long-form investment reports via GPT-4 (openai)
  • 📊 Combines multiple valuation methods (DCF, PE, Book Value, Dividend, Relative)
  • 📉 Generates fair value charts and overlays them with market price
  • 🧾 Formats GPT outputs into clean, styled HTML with tables and insights
  • 🌍 Reports are generated in Spanish with financial terminology in English

🧠 GPT-Powered Reporting

Once the analysis is complete, GPT-4 generates a 5000+ word structured investment report including:

  • Market & Industry Summary
  • Fundamental & Technical Analysis
  • Investment & Trading Strategy
  • Executive Summary in Spanish

🛠️ Installation

  1. Clone the repository

    git clone hhttps://github.com/ESJavadex/stockgpt.git
    cd stockgpt
  2. Install dependencies
    It's recommended to use a virtual environment.

    pip install -r requirements.txt
  3. Set up environment variables
    Create a .env file:

    OPENAI_API_KEY=your_openai_api_key
    
  4. Run the app (Locally)

    python scrap.py

    The app runs locally on http://localhost:5007


🐳 Run with Docker

  1. Build and run with Docker Compose

    docker compose up --build

    The app will be accessible at http://0.0.0.0:5003 (host port 5003 mapped to container port 5007).

  2. (Optional) Run with Docker only

    docker build -t stockgpt .
    docker run -p 5003:5007 --env OPENAI_API_KEY=your_openai_api_key stockgpt


🖼️ Example

Stock Analysis Interface


🔧 Tech Stack

  • Python + Flask
  • Selenium (ChromeDriver)
  • yfinance + matplotlib + pandas
  • OpenAI GPT-4 API
  • Bootstrap for frontend styling
  • Markdown parsing & HTML post-processing

📂 Project Structure

📦 stockgpt/
├── templates/
│   └── index_scrap.html      # HTML frontend
├── scrap.py                  # Main Flask server with GPT integration
├── .env                      # Environment variables (not tracked in Git)
├── image.png                 # Example output chart
├── requirements.txt          # Python dependencies
├── Dockerfile                # Docker image definition
└── docker-compose.yml        # Docker Compose configuration

✨ Example Use

  1. Search for a stock symbol (e.g. AAPL, MSFT, NVDA)
  2. View the full analysis generated by GPT-4 with valuation insights
  3. Download the valuation chart directly

📌 Notes

  • Ensure you have chromedriver installed and in your PATH for Selenium.
  • GPT-4.1 usage may incur API costs depending on request length.

📄 License

MIT License. Feel free to modify and use as needed.

About

StockGPT is a Flask-based web application that scrapes real-time stock data, performs fundamental and technical analysis, and generates professional investment reports using GPT-4. It supports advanced valuation models such as DCF, PE, Book Value, and Dividend Discount, with visual fair value comparisons and markdown-to-HTML reporting.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published