A high-frequency, ML-backed trading engine designed for scalping Nifty 50 Options. It uses a hybrid architecture with Go for low-latency execution and Python for machine learning inference.
-
Hybrid Architecture: Go for speed, microservices and concurrency; Python for real-time data intelligence and time-series.
-
Real-time Scalping: Targets 1-3 point scalps on Nifty 50.
-
Ghost Mode: Test strategies with paper money before risking real capital.
-
Smart Order Execution: Uses Zerodha Kite Connect API for direct market access.
-
Web-based Dashboard: Monitor trades, P&L, and system health in real-time.
-
Auto-Recovery: Built-in logic to handle network disconnects and resume trading.
The system is split into three decoupled microservices:
-
Connects to Zerodha Kite Ticker (Websockets).
-
Manages "Ghost Mode" vs. "Live Execution".
-
Handles Order Management System (OMS) and risk checks.
-
Communcates with the Brain via gRPC.
-
Runs an XGBoost model trained on technical indicators (RSI, MACD, Bollinger Bands).
-
Receives real-time ticks, calculates feature vectors, and returns probabilities.
-
Exposes a gRPC endpoint (GetPrediction).
-
Real-time visualization of market ticks and trade logic.
-
Manual "Kill Switch" and configuration.
-
Languages: Go (Golang) 1.21+, Python 3.11+
-
Broker API: Zerodha Kite Connect
-
Machine Learning: XGBoost, Pandas, TA-Lib/Pandas-TA, yfinance
-
Communication: gRPC (Protobuf), WebSockets
-
Database: QuestDB (Tick storage), PostgreSQL (Trade logs)
-
Frontend: Next.js 14, TailwindCSS, Recharts
-
Docker & Docker Compose
-
Go 1.21+
-
Python 3.11+
-
Node.js 20+
-
Zerodha Kite API Key & Secret
git clone https://github.com/yourusername/trade-engine.git
cd trade-engineCreate a root .env file:
# Zerodha Credentials
KITE_API_KEY=your_api_key
KITE_API_SECRET=your_api_secret
KITE_REQUEST_TOKEN= # Updated manually daily
# System Configuration
MODE=LIVE # SIMULATION or LIVE
TRADING_ENABLED=false # Safety switch (false = Ghost Mode)
BRAIN_URL=localhost:50051
# Kindly put both the db urls, name, password, dbname, port, etc in env after running them on local system# windows
./start_all.ps1
# linux
chmod +x start_all.sh
./start_all.sh
# mac
chmod +x start_all.command
./start_all.commandInstall dependencies and train the initial model:
cd brain
poetry install # or pip install -r requirements.txt
python train.py # Downloads data from yfinance and generates model.json
python server.py # Starts the gRPC inference engineRun the execution engine:
cd backend
go mod tidy
go run main.go
# Follow the terminal prompt to login to Zerodha if token is expired.cd frontend
npm install
npm run dev
# Visit http://localhost:3000 to view the trading desk.Before going live, verify your strategy:
cd brain
python backtest.py
# Check the generated equity_curve.png to ensure positive expectancy.-
Set TRADING_ENABLED=false in .env.
-
Start the Go backend.
-
Watch the logs. The bot will process real live ticks and simulate orders:
🤖 [GHOST] Would have BOUGHT NIFTY26FEB24500CE at 120.50-
Verify Ghost Mode performance for at least 1 hour.
-
Set TRADING_ENABLED=true.
-
Restart the Backend.
-
Monitor the dashboard closely. Use the UI "Stop" button to kill the engine instantly if needed.
-
Options trading involves significant risk. This software is for educational purposes. The authors are not responsible for financial losses incurred by using this bot.
-
Always test in "Ghost Mode" first.
-
Keep TRADING_ENABLED=false until you are 100% sure.
-
Hardcode a MAX_LOSS limit in the Go backend.