AI-Powered Stock Trading Platform with Natural Language Commands
Trade stocks using simple commands like "Buy 10 Apple stocks" or "What's Coal India worth?"
- Natural Language Trading: Use plain English to buy/sell stocks
- AI-Powered NLP: Google Gemini API with pattern-based fallback
- Multi-Market Support: US stocks (AAPL, TSLA) & Indian stocks (COALINDIA.NS, RELIANCE.NS)
- Real-Time Data: NSE India for Indian stocks, Alpha Vantage for US stocks
- Portfolio Management: Track holdings, cash balance, and trade history
- AI Predictions: ML-based price predictions with confidence scores
- Secure Authentication: JWT-based auth with bcrypt password hashing
- Docker Desktop (Windows/Mac) or Docker Engine (Linux)
- 8GB RAM available
- Ports 3000, 8000, 5432, 6379 free
git clone <your-repo-url>
cd onecommandGenerate SECRET_KEY (Windows PowerShell):
$bytes = New-Object Byte[] 32
[Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
$key = [System.BitConverter]::ToString($bytes).Replace("-","").ToLower()
Write-Host "Your SECRET_KEY: $key"Or using bash/WSL:
openssl rand -hex 32Edit .env - Replace your_generated_secret_key_here with the key above:
SECRET_KEY=<paste_generated_key_here>
# Optional: Add real API keys (works with demo data without these)
ALPHA_VANTAGE_KEY=your_key_here
FINNHUB_KEY=your_key_here
GEMINI_API_KEY=your_key_heredocker-compose up -dWait for services to start (~30-60 seconds):
docker-compose psExpected output - all services should show "Up" or "Up (healthy)":
NAME STATUS
onecommand_backend Up (healthy)
onecommand_frontend Up
onecommand_postgres Up (healthy)
onecommand_redis Up (healthy)
onecommand_mcp Up
- Frontend: http://localhost:3000
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
Email: demo@onecommand.com
Password: demo123
"Buy 10 Apple stocks"
"What's Tesla worth?"
"Show my portfolio"
"Buy 5 shares of Coal India"
"Sell all my Google shares"
Trading:
- "Buy 10 shares of Apple"
- "Purchase 5 Coal India stocks"
- "Sell all my Tesla"
- "Sell 3 shares of Google"
Price Queries:
- "What's Apple worth?"
- "Show me Coal India price"
- "How much is Tesla?"
Portfolio:
- "Show my portfolio"
- "What do I own?"
- "My holdings"
US Stocks: Use ticker symbols (AAPL, TSLA, MSFT, GOOGL, AMZN)
Indian Stocks: Use .NS suffix (RELIANCE.NS, COALINDIA.NS, TCS.NS, INFY.NS)
Frontend (React + Vite)
β REST API
Backend (FastAPI + Python)
β
βββ PostgreSQL (portfolio/trades)
βββ Redis (caching)
βββ Gemini AI (NLP)
βββ NSE India (Indian stock data)
βββ Alpha Vantage (US stock data)
βββ ML Service (predictions)
Tech Stack:
- Frontend: React, Vite, TailwindCSS, Lucide Icons
- Backend: FastAPI, SQLAlchemy, Pydantic
- Database: PostgreSQL, Redis
- AI/ML: Google Gemini API, scikit-learn, transformers
- Stock Data: nsepy (NSE India), Alpha Vantage, YFinance
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f backend
docker-compose logs -f frontend# All services
docker-compose restart
# Specific service
docker-compose restart backenddocker-compose down -v
docker-compose up -d --build# PostgreSQL shell
docker exec -it onecommand_postgres psql -U postgres -d postgres_db
# Redis CLI
docker exec -it onecommand_redis redis-cli- Generate Secure SECRET_KEY (see Quick Start section)
- Change Default Credentials in production
- Use HTTPS with SSL certificates
- Set Proper CORS Origins in
.env - Revoke Exposed API Keys (see SECURITY_NOTICE.md)
.env files or API keys to version control!
POST /api/auth/register- Register new userPOST /api/auth/login- Login and get tokenGET /api/auth/me- Get current user info
POST /api/command- Process natural language commandGET /api/portfolio- Get user portfolioGET /api/trades- Get trade history
GET /api/stocks/{symbol}/prediction- Get AI predictionGET /api/stocks/{symbol}/sentiment- Get sentiment analysis
Full API documentation: http://localhost:8000/docs
For production deployment, see DEPLOYMENT.md which covers:
- Security hardening
- Environment configuration
- SSL/HTTPS setup
- Database backups
- Monitoring and logging
- Cloud deployment options (Railway, Render, Fly.io)
# Check what's running
docker-compose ps
# View logs
docker-compose logs
# Clean restart
docker-compose down -v
docker-compose up -d --build# Windows: Find process using port
netstat -ano | findstr :3000
taskkill /PID <process_id> /F
# Linux/Mac: Find and kill process
lsof -ti:3000 | xargs kill -9# Verify database is running
docker-compose ps postgres
# Check database logs
docker-compose logs postgres
# Wait for database to be ready (30 seconds)# Restart backend after updating .env
docker-compose restart backend
# Verify keys are loaded
docker exec onecommand_backend env | grep KEYContributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see LICENSE file for details
- Security Notice: SECURITY_NOTICE.md
- Deployment Guide: DEPLOYMENT.md
- API Documentation: http://localhost:8000/docs
Built with β€οΈ using FastAPI, React, and Google Gemini AI
π Star this repo if you find it useful!