A full-stack stock prediction platform combining Next.js frontend with Python FastAPI backend. Features PyTorch LSTM neural networks for price forecasting, Alpha Vantage API integration, and interactive data visualization.
- Node.js 18.0 or higher
- Python 3.8 or higher
- pip package manager
- Modern web browser
```bash
npm run setup
NEXT_PUBLIC_API_URL=http://localhost:8000
=======
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_URL=http://localhost:8000
npm run dev:full ```
Alternative Manual Setup: ```bash
npm install
cd backend pip install -r requirements.txt cd ..
npm run dev:full ```
If you get "'concurrently' is not recognized" error: ```bash
rm -rf node_modules package-lock.json npm install npm run dev:full ```
If you get "Missing script" errors:
- Make sure you're in the root directory (not in
/backend) - Run
npm installfirst to installconcurrently
If PyTorch installation fails:
- The requirements.txt uses PyTorch 2.7.1 (latest compatible version)
- For older systems, you may need to install PyTorch separately:
pip install torch torchvision
If backend connection fails:
- The frontend works without the backend (shows fallback data)
- To use real ML predictions, ensure both servers are running
- Check that
NEXT_PUBLIC_API_URL=http://localhost:8000is set - Verify that
ALPHA_VANTAGE_API_KEYis set with a valid API key - Verify that
ALPHA_VANTAGE_API_KEYis set with a valid API key
-
Interactive price and volume charts
-
Popular stocks quick access
-
Real-time data from Alpha Vantage (API key required) =======
-
Real-time data from Alpha Vantage API
-
Technical indicators and pattern analysis
-
Real-time data from Alpha Vantage API
-
Technical indicators and pattern analysis
- Real PyTorch LSTM models (not simulations)
- Multiple architectures: LSTM, GRU, Transformer
- Live model training with progress tracking
- Performance metrics: RMSE, MAE, directional accuracy
- Interactive hyperparameter tuning
- Real-time training visualization
- Model comparison and persistence
Hybrid Stack:
-
Frontend: Next.js + React + TypeScript
-
Backend: FastAPI + PyTorch + Python
-
Data: Alpha Vantage (API key required) =======
-
Data: Alpha Vantage API (requires API key)
-
Data: Alpha Vantage API (requires API key)
-
ML: Real neural networks with GPU support
-
Deployment: Docker-ready with environment variable configuration
-
Deployment: Docker-ready with environment variable configuration
Project Structure: ``` βββ app/ # Next.js frontend application βββ app/ # Next.js frontend application β βββ components/ # React components β βββ lib/ # API client and utilities β βββ styles/ # CSS and styling β βββ lib/ # API client and utilities β βββ styles/ # CSS and styling βββ backend/ β βββ models/ # PyTorch LSTM models β βββ data/ # Data fetching & preprocessing β β βββ alpha_vantage_fetcher.py # Alpha Vantage API integration β βββ main.py # FastAPI application β β βββ alpha_vantage_fetcher.py # Alpha Vantage API integration β βββ main.py # FastAPI application β βββ utils/ # Training & model management βββ .env.local # Environment variables βββ docker-compose.yml # Docker configuration βββ .env.local # Environment variables βββ docker-compose.yml # Docker configuration ```
Accuracy Benchmarks:
- Large Cap Stocks: 65-75% directional accuracy
- RMSE: $3-8 for major stocks (AAPL, MSFT)
- Best Performance: 1-7 day predictions
- Limitations: Cannot predict news events or market crashes
Performance by Time Horizon:
- 1-3 days: 70-75% accuracy
- 1 week: 60-70% accuracy
- 1 month: 50-60% accuracy
- 3+ months: Approaches random (not recommended)
```bash
npm run dev # Frontend only npm run dev:full # Both frontend + backend npm run setup # Install all dependencies
npm run backend:start # Start Python API server npm run backend:install # Install Python dependencies
npm run build # Build frontend npm start # Start production server ```
Environment Variables:
NEXT_PUBLIC_API_URL- Backend URL (required)- Development:
http://localhost:8000 - Production: Your deployed backend URL
- Development:
ALPHA_VANTAGE_API_KEY- API key for Alpha Vantage (required)- Get a free key at: https://www.alphavantage.co/support/#api-key
ALPHA_VANTAGE_API_KEY- API key for Alpha Vantage (required)- Get a free key at: https://www.alphavantage.co/support/#api-key
Model Parameters:
- Hidden Size: 16-256 (default: 64)
- Layers: 1-6 (default: 2)
- Learning Rate: 0.0001-0.01 (default: 0.001)
- Sequence Length: 10-60 days (default: 30)
Recommended: Vercel + Railway ```bash
vercel deploy
railway login && railway deploy ```
Docker Option: ```bash docker-compose up --build ```
Data Source: Uses Alpha Vantage API (requires free API key) Data Source: Uses Alpha Vantage API (requires free API key)
- Free tier has limitations on request frequency (5 calls per minute, 500 per day)
- Consider upgrading to a paid plan for production use
Model Limitations:
- Cannot predict black swan events, earnings surprises, or news impacts
- Accuracy decreases significantly for predictions beyond 30 days
- Best used for short-term trend analysis, not investment decisions
- Model performance depends on quality and quantity of training data
- Model performance depends on quality and quantity of training data
Disclaimer: For educational purposes only. Not financial advice.
MIT License - see LICENSE file.
Tech Stack: Next.js β’ FastAPI β’ PyTorch β’ Alpha Vantage β’ TypeScript β’ Python Tech Stack: Next.js β’ FastAPI β’ PyTorch β’ Alpha Vantage β’ TypeScript β’ Python