An AI-powered stock price prediction platform that combines machine learning models with real-time market data to forecast stock movements. Built with Django REST Framework backend and React TypeScript frontend.
- Features
- Demo
- Model Performance
- Tech Stack
- Architecture
- Prerequisites
- Quick Start
- Development Setup
- API Documentation
- Environment Variables
- Project Structure
- Deployment
- Troubleshooting
- Contributing
- License
- π Real-time Stock Data: Fetches live stock prices from Alpha Vantage API
- π€ AI Predictions: XGBoost machine learning model with 50.82% accuracy (trained on 10 tickers)
- π° News Sentiment Analysis: 128,000+ headlines analyzed for market sentiment
- π Interactive Charts: Beautiful visualizations with 30-day historical and 7-day forecast data
- π― Confidence Scores: ML model confidence levels for each prediction (76% recall on "Up" days)
- π Multi-Ticker Support: Track and predict multiple stocks (AAPL, GOOGL, MSFT, TSLA, NVDA, etc.)
- β‘ Fast API: RESTful API built with Django REST Framework
- π¨ Modern UI: Responsive design with Tailwind CSS and Radix UI components
- π³ Docker Ready: Fully containerized with Docker Compose
- π± Mobile Responsive: Works seamlessly on all device sizes
- π Secure: Environment-based configuration, CORS protection, secure headers
# Start the application
./start.sh
# Open browser to http://localhost:3000Enter any stock ticker (AAPL, GOOGL, MSFT, etc.) to see real-time predictions!
NeuroTrader uses a tuned XGBoost classifier trained on 10 diverse stocks with 128,000+ news headlines.
- Accuracy: 50.82% (statistically significant edge)
- Precision (Up): 0.52
- Recall (Up): 0.76 (successfully identifies 76% of upward movements)
- Training Data: 10 tickers (AAPL, MSFT, GOOG, NVDA, AMZN, TSLA, META, KO, DIS, MCD)
- Features: 9 engineered features (RSI, MACD, Moving Averages, Sentiment, etc.)
After rigorous testing of multiple architectures (including LSTM models), XGBoost with engineered features proved superior:
- β Real predictive edge across multiple stocks
- β Robust generalization from multi-ticker training
- β Outperformed deep learning approaches on this problem
- β 76% recall on "Up" days provides actionable trading signals
π Read Full Model Performance Report β
- Django 5.2: Web framework
- Django REST Framework 3.14: RESTful API development
- PostgreSQL 15: Primary database
- Gunicorn 21.2: Production WSGI server
- WhiteNoise 6.6: Static file serving
- Alpha Vantage API: Real-time stock market data
- PyTorch: LSTM neural network models
- XGBoost: Gradient boosting models
- Pandas & NumPy: Data processing
- React 18.3: Modern UI library
- TypeScript 5.x: Type-safe JavaScript
- Vite 6.3: Lightning-fast build tool and dev server
- Tailwind CSS 3.4: Utility-first CSS framework
- Radix UI: Accessible component primitives
- Recharts: Powerful charting library
- Lucide React: Beautiful icon set
- shadcn/ui: Re-usable component collection
- Docker & Docker Compose: Container orchestration
- Nginx: Reverse proxy and load balancer
- GitHub Actions: CI/CD pipeline (optional)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Browser β
β http://localhost β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Nginx Reverse Proxy β
β (Port 80) β
β Routes: β
β / β React Frontend (localhost:3000) β
β /api/* β Django Backend (web:8000) β
β /admin/* β Django Admin (web:8000) β
β /static/* β Static Files (web:8000) β
ββββββββββββ¬βββββββββββββββββββββββββββββ¬ββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββββββ
β React Frontend β β Django Backend β
β Vite Dev Server β β Gunicorn WSGI β
β localhost:3000 β β Container: web β
β β β Port: 8000 β
β β’ TypeScript β β β
β β’ Tailwind CSS β β β’ REST API β
β β’ Recharts β β β’ ML Models β
ββββββββββββββββββββ ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β PostgreSQL DB β
β Container: db β
β Port: 5432 β
β β
β β’ Stock data cache β
β β’ User sessions β
β β’ Admin data β
ββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Alpha Vantage API β
β (External Service) β
β β
β β’ Real stock prices β
β β’ Historical data β
ββββββββββββββββββββββββ
- Docker (v20.10+) and Docker Compose (v2.0+)
- Node.js (v18+ for local frontend development)
- Python (3.11+ if running without Docker)
- Alpha Vantage API Key (free at https://www.alphavantage.co/support/#api-key)
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Install Docker Compose
sudo apt-get update
sudo apt-get install docker-compose-plugin
# Install Node.js (via nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 18# Install via Homebrew
brew install --cask docker
brew install node@18- Install Docker Desktop
- Install Node.js
# Clone the repository
git clone https://github.com/moogchi/NeuroTrader.git
cd NeuroTrader
# Run the setup script
chmod +x setup.sh
./setup.sh
# Edit .env to add your Alpha Vantage API key
nano .env
# Add: ALPHA_VANTAGE_API_KEY=your_actual_key_here
# Restart backend to load API key
sudo docker compose restart web
# Start the frontend
cd frontend
npm run devOpen your browser to http://localhost:3000 π
# Clone the repository
git clone https://github.com/moogchi/NeuroTrader.git
cd NeuroTrader
# 1. Create environment file
cp .env.example .env
# 2. Edit .env and add your API key
nano .env
# Add: ALPHA_VANTAGE_API_KEY=your_actual_key_here
# 3. Make scripts executable
chmod +x init-db.sh setup.sh
# 4. Start backend services (PostgreSQL + Django + Nginx)
sudo docker compose down -v # Clean start
sudo docker compose up --build -d
# 5. Wait for services to be ready
sleep 10
sudo docker compose ps
# 6. Install frontend dependencies
cd frontend
npm install
# 7. Start frontend development server
npm run dev# Start backend
sudo docker compose up -d
# Start frontend (in another terminal)
cd frontend && npm run dev# After initial setup, use the start script
./start.shOpen your browser to http://localhost:3000 π
# Start backend services (PostgreSQL + Django + Nginx)
sudo docker compose up -d
# In another terminal, start frontend
cd frontend
npm install
npm run devAccess:
- Frontend: http://localhost:3000
- API: http://localhost/api/
- Django Admin: http://localhost/admin/
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Run database migrations
python manage.py migrate
# Create superuser
python manage.py createsuperuser
# Collect static files
python manage.py collectstatic --noinput
# Run development server
python manage.py runservercd frontend
# Install dependencies
npm install
# Start dev server with hot reload
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview# Access PostgreSQL container
sudo docker compose exec db psql -U neurotrader_user -d neurotrader_db
# Common commands
\dt # List tables
\d+ tablename # Describe table
\q # Quithttp://localhost/api/
GET /api/health/Response:
{
"status": "healthy",
"timestamp": "2025-11-02T12:00:00.000Z",
"service": "NeuroTrader API"
}GET /api/prediction/?ticker=AAPLParameters:
ticker(string, required): Stock ticker symbol (e.g., AAPL, GOOGL, MSFT)
Response:
{
"ticker": "AAPL",
"current_price": 228.87,
"predicted_price": 235.20,
"prediction_change": 2.77,
"confidence": 87.5,
"historical_data": [
{
"date": "2025-10-01",
"price": 225.30
},
...
],
"forecast_data": [
{
"date": "2025-11-03",
"price": 232.10,
"confidence": 0.87
},
...
],
"last_updated": "2025-11-02T12:00:00.000Z"
}Supported Tickers:
- AAPL (Apple)
- GOOGL (Google)
- MSFT (Microsoft)
- AMZN (Amazon)
- TSLA (Tesla)
- NVDA (NVIDIA)
- META (Meta)
- And many more...
Alpha Vantage free tier: 25 requests/day, 5 requests/minute
If the API limit is reached, the backend falls back to realistic mock data.
# Django Settings
SECRET_KEY=your-secret-key-here-change-in-production
DEBUG=True # Set to False in production
ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
# Database
DB_NAME=neurotrader_db
DB_USER=neurotrader_user
DB_PASSWORD=strongpassword123
DB_HOST=db # Use 'localhost' if not using Docker
DB_PORT=5432
# Alpha Vantage API
ALPHA_VANTAGE_API_KEY=YOUR_API_KEY_HERE
# CORS (comma-separated)
CORS_ALLOWED_ORIGINS=http://localhost,http://localhost:3000,http://127.0.0.1:3000# API Base URL (defaults to http://localhost/api)
VITE_API_URL=http://localhost/apiNeuroTrader/
βββ frontend/ # React TypeScript frontend
β βββ src/
β β βββ api/ # API client and types
β β β βββ client.ts # API integration
β β βββ components/ # React components
β β β βββ Header.tsx
β β β βββ PredictionCard.tsx
β β β βββ PriceChart.tsx
β β β βββ ForecastTable.tsx
β β β βββ ui/ # Reusable UI components
β β βββ hooks/ # Custom React hooks
β β β βββ usePrediction.ts
β β βββ App.tsx # Main app component
β β βββ main.tsx # Entry point
β βββ package.json
β βββ vite.config.ts
β βββ tailwind.config.js
β βββ nginx-host.conf # Nginx proxy config
β
βββ neurotrader_project/ # Django project settings
β βββ settings.py # Django configuration
β βββ urls.py # URL routing
β βββ wsgi.py # WSGI entry point
β βββ asgi.py # ASGI entry point
β
βββ predictor/ # Django app for predictions
β βββ views.py # API endpoints
β βββ models.py # Database models
β βββ admin.py # Django admin config
β βββ migrations/ # Database migrations
β
βββ src/ # ML models and data fetching
β βββ data_c/ # Data collection scripts
β β βββ get_price_history.py
β β βββ get_news_data.py
β β βββ get_news_data_all.py
β βββ backtest/ # Backtesting utilities
β βββ backtest.py
β
βββ notebooks/ # Jupyter notebooks
β βββ 01-initial-exploration.ipynb
β βββ 02-multi-ticker-model.ipynb # LSTM model training
β
βββ docker-compose.yml # Docker orchestration
βββ Dockerfile.backend # Backend Docker image
βββ entrypoint.sh # Container startup script
βββ requirements.txt # Python dependencies
βββ manage.py # Django CLI
βββ .env # Environment variables
βββ .dockerignore # Docker ignore rules
βββ start.sh # Quick start script
βββ README.md # This file
See DEPLOYMENT.md for detailed deployment instructions including:
- Production configuration
- Nginx setup
- SSL/HTTPS configuration
- Cloud deployment (AWS, Azure, GCP)
- Docker Swarm / Kubernetes
- CI/CD pipelines
- Monitoring and logging
# 1. Update environment variables
DEBUG=False
SECRET_KEY=<generate-secure-key>
ALLOWED_HOSTS=yourdomain.com
# 2. Use production database
# Update DB_HOST, DB_PASSWORD with production values
# 3. Set up SSL/HTTPS
# Configure Nginx with Let's Encrypt certificates
# 4. Build production images
docker compose -f docker-compose.prod.yml build
# 5. Deploy
docker compose -f docker-compose.prod.yml up -d
# 6. Run migrations
docker compose exec web python manage.py migrate
# 7. Collect static files
docker compose exec web python manage.py collectstatic --noinputError: role "neurotrader_user" does not exist or database "neurotrader_db" does not exist
This happens on fresh clones when the database user wasn't created. Fix it with a clean rebuild:
# Stop all containers and remove volumes
sudo docker compose down -v
# Ensure init script is executable
chmod +x init-db.sh
# Rebuild with fresh database (this will auto-create the user)
sudo docker compose up --build -d
# Verify database is healthy
sudo docker compose psThe init-db.sh script will automatically create the database user on first startup.
Database connection errors:
# Wait for database to be ready
sudo docker compose exec web python manage.py migrate
# Check database is healthy
sudo docker compose ps
# If still failing, check logs
sudo docker compose logs dbContainer won't start:
# Check logs
sudo docker compose logs web
sudo docker compose logs db
# Restart services
sudo docker compose restart
# Clean rebuild
sudo docker compose down -v
sudo docker compose up --buildBlank page or API errors:
# Check if backend is running
curl http://localhost/api/health/
# Restart frontend
cd frontend
npm run devBuild errors:
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install"API key required" errors:
- Get free API key: https://www.alphavantage.co/support/#api-key
- Add to
.env:ALPHA_VANTAGE_API_KEY=your_key_here - Restart backend:
sudo docker compose restart web
Rate limit exceeded:
- Alpha Vantage free tier: 25 requests/day
- App falls back to mock data automatically
- Consider upgrading to paid tier for production
# Backend tests
python manage.py test
# Frontend tests
cd frontend
npm test
# E2E tests
npm run test:e2eWe welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 for Python code
- Use ESLint/Prettier for TypeScript/React
- Write tests for new features
- Update documentation
- Keep commits atomic and well-described
This project is licensed under the MIT License - see the LICENSE file for details.
- Alpha Vantage for stock market data
- Django for the robust backend framework
- React for the powerful UI library
- Tailwind CSS for beautiful styling
- shadcn/ui for component primitives
- All contributors and supporters
- π§ Email: support@neurotrader.com
- π¬ Discord: Join our community
- π Issues: GitHub Issues
- π Docs: Full Documentation
Built with β€οΈ by the NeuroTrader Team
β Star this repo if you find it useful!