Institutional-Grade Automated Trading Platform for Indian Stock Markets
Quantbox is a full-stack algorithmic trading platform designed for the Indian equities market. It provides automated strategy execution, backtesting, paper trading, live trading integration with Angel One SmartAPI, and a community marketplace for sharing strategies.
- Features
- Architecture
- Tech Stack
- Project Structure
- Getting Started
- Production Deployment
- Trading Strategies
- API Reference
- Security
- Database Schema
- Troubleshooting
- License
- Live Trading: Real-time execution via Angel One SmartAPI with SEBI-compliant IP verification
- Paper Trading: Simulated execution with live market data for strategy validation
- Backtesting: Historical performance analysis with comprehensive metrics
- 40+ Pre-built Strategies: Trend following, mean reversion, momentum, and institutional strategies
- 20+ AI/ML Strategies: LSTM, Transformer, XGBoost, Reinforcement Learning models
- Strategy Builder: Visual drag-and-drop strategy composition
- Custom Parameters: Fine-tune every strategy parameter
- Risk Management: Stop-loss, take-profit, trailing stops, position sizing
- Real-time Charts: Interactive candlestick charts with technical indicators
- Sentiment Analysis: AI-powered market sentiment from news and social media
- Performance Metrics: Sharpe ratio, Sortino ratio, max drawdown, profit factor
- Trade History: Comprehensive logging with P&L tracking
- Kill Switch: Emergency halt for all automated trading
- Strategy Marketplace: Share and copy strategies from other traders
- Ratings & Reviews: Community feedback on published strategies
- Leaderboards: Top performing strategies and traders
- AES-256-GCM Encryption: All sensitive credentials encrypted at rest
- Two-Factor Authentication: TOTP-based 2FA with backup codes
- Account Lockout: Automatic lockout after failed login attempts
- Security Audit Logging: Comprehensive audit trail
- IP Whitelisting: SEBI-compliant trading IP verification
┌─────────────────────────────────────────────────────────────────┐
│ NGINX (Reverse Proxy) │
│ SSL Termination + Load Balancing │
└─────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────┐ ┌─────────────────────────────┐
│ Next.js Frontend (3000) │ │ FastAPI Backend (8000) │
│ - Dashboard UI │ │ - Trading Engine │
│ - Strategy Builder │ │ - Backtest Engine │
│ - Charts & Analytics │ │ - Sentiment Analysis │
│ - Authentication │ │ - Angel One Integration │
│ - API Routes │ │ - WebSocket Feeds │
└─────────────────────────────────┘ └─────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ PostgreSQL Database (5432) │
│ Users, Trades, Strategies, Performance, Audit │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Redis (6379) │
│ Session Cache, Rate Limiting, Pub/Sub │
└─────────────────────────────────────────────────────────────────┘
| Technology | Purpose |
|---|---|
| Next.js 15 | React framework with App Router |
| TypeScript | Type-safe development |
| Tailwind CSS 4 | Utility-first styling |
| Radix UI | Accessible component primitives |
| Lightweight Charts | Financial charting |
| Framer Motion | Animations |
| NextAuth.js | Authentication |
| Technology | Purpose |
|---|---|
| FastAPI | High-performance Python API |
| SQLAlchemy | Async ORM |
| APScheduler | Scheduled tasks |
| SmartAPI | Angel One broker integration |
| NumPy | Technical indicator calculations |
| Loguru | Structured logging |
| Technology | Purpose |
|---|---|
| PostgreSQL 15 | Primary database |
| Redis 7 | Caching and sessions |
| Docker | Containerization |
| NGINX | Reverse proxy and SSL |
| Certbot | SSL certificate management |
autotradesync-trading-system/
├── backend/
│ ├── app/
│ ├── Dockerfile
│ └── requirements.txt
├── public/
├── src/
├── Dockerfile
├── docker-compose.yml
├── docker-compose.prod.yml
├── init.sql
├── nginx.conf
└── ...
- Docker & Docker Compose
-
Clone the repository:
git clone https://github.com/your-repo/autotradesync-trading-system.git cd autotradesync-trading-system -
Start the development environment:
docker-compose up --build
This command will build the Docker images and start all the services, including PostgreSQL, Redis, the backend, and the frontend. The services will be available at:
- Frontend:
http://localhost:3000 - Backend:
http://localhost:8000 - Backend Docs:
http://localhost:8000/docs
- Frontend:
- A server with Docker and Docker Compose installed.
- A domain name pointing to your server's IP address.
-
Clone the repository on your server:
git clone https://github.com/your-repo/autotradesync-trading-system.git cd autotradesync-trading-system -
Configure environment variables:
Create a
.envfile and add your production environment variables. You can use.env.exampleas a template.cp .env.example .env nano .env
-
Configure Nginx:
Edit
nginx.confand replaceyourdomain.comwith your actual domain name.sed -i 's/yourdomain.com/your-actual-domain.com/g' nginx.conf -
Deploy the application:
docker-compose -f docker-compose.prod.yml up -d --build
-
Obtain SSL certificates:
Use the
certbotservice defined indocker-compose.prod.ymlto obtain SSL certificates from Let's Encrypt.docker-compose -f docker-compose.prod.yml run --rm certbot certonly --webroot --webroot-path=/var/www/certbot --email your-email@example.com --agree-tos --no-eff-email -d yourdomain.com
-
Restart Nginx:
After obtaining the certificates, restart the Nginx container to apply the changes.
docker-compose -f docker-compose.prod.yml restart nginx
... (rest of the file remains the same)