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.
- 🔍 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
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
-
Clone the repository
git clone hhttps://github.com/ESJavadex/stockgpt.git cd stockgpt
-
Install dependencies
It's recommended to use a virtual environment.pip install -r requirements.txt
-
Set up environment variables
Create a.env
file:OPENAI_API_KEY=your_openai_api_key
-
Run the app (Locally)
python scrap.py
The app runs locally on
http://localhost:5007
-
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).
-
(Optional) Run with Docker only
docker build -t stockgpt . docker run -p 5003:5007 --env OPENAI_API_KEY=your_openai_api_key stockgpt
- Python + Flask
- Selenium (ChromeDriver)
- yfinance + matplotlib + pandas
- OpenAI GPT-4 API
- Bootstrap for frontend styling
- Markdown parsing & HTML post-processing
📦 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
- Search for a stock symbol (e.g.
AAPL
,MSFT
,NVDA
) - View the full analysis generated by GPT-4 with valuation insights
- Download the valuation chart directly
- Ensure you have
chromedriver
installed and in your PATH for Selenium. - GPT-4.1 usage may incur API costs depending on request length.
MIT License. Feel free to modify and use as needed.