Intraday paper trading system for NSE stocks using Upstox live data, candlestick pattern detection, and a real-time web dashboard.
- Python 3.11+
- Node.js 18+
- TA-Lib C library (must be installed before
pip install) - Upstox developer account — developer.upstox.com
git clone <repo-url>
cd tech-analyzer
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS / Linuxpip install -e .cp .env.example .envEdit .env and fill in your Upstox API credentials:
UPSTOX_API_KEY=your-api-key
UPSTOX_API_SECRET=your-api-secret
UPSTOX_REDIRECT_URI=http://127.0.0.1:8000/callback
cd web
npm install
cd ..uvicorn tech_analyzer.web.app:app --reload --port 8000Upstox tokens expire at end of each trading day.
With the server running, open this in your browser:
http://localhost:8000/api/auth/url
Copy the URL from the JSON response, open it, log in with your Upstox credentials. You will be redirected back and shown a "Login successful" page. The token is saved automatically — no restart needed.
Check auth status:
http://localhost:8000/api/auth/status
http://localhost:8000
Click ▶ Start, choose your watchlist, interval, and capital, then start the session.
Run two terminals simultaneously:
Terminal 1 — backend (auto-reloads on Python changes):
uvicorn tech_analyzer.web.app:app --reload --port 8000Terminal 2 — frontend (instant browser hot-reload):
cd web
npm run devOpen http://localhost:5173 — API and WebSocket calls are proxied to port 8000.
No npm run build needed while developing.
When you want the backend to serve the frontend directly at port 8000:
cd web
npm run build
cd ..
uvicorn tech_analyzer.web.app:app --port 8000# Authenticate
python -m tech_analyzer --auth
# Paper trade (Bank Nifty, 15m candles, ₹2L capital)
python -m tech_analyzer --paper --watchlist nifty_bank --interval 15m --capital 200000
# Backtest
python -m tech_analyzer --symbol RELIANCE.NS --backtesttech_analyzer/
data/ Upstox API: live candles, LTP, instrument lookup, auth
patterns/ Candlestick pattern detection (TA-Lib)
trading/ Paper trading: portfolio, engine, session, EOD report
web/ FastAPI backend: REST API, WebSocket broadcaster, auth
screener/ Watchlists (nifty_bank, nifty50)
cli.py Entry point for --auth / --paper / --backtest
web/ React + Vite frontend
src/
components/ SessionControls, SymbolTable, TradeFeed, CandleChart, ...
ws/ WebSocket client (useWebSocket hook, event types)
api/ REST API client
output/
paper_trading/ EOD charts saved here (PNG per instrument, per day)
~/.tech_analyzer/
upstox_token.json Cached auth token
paper_portfolio.json Persisted portfolio state (survives restarts)
instruments_*.csv Cached Upstox instrument master
| Parameter | Default | Description |
|---|---|---|
| Watchlist | nifty_bank |
nifty_bank or nifty50 |
| Interval | 15m |
1m 5m 15m 30m 1h |
| Capital | ₹1,00,000 | Starting paper capital |
| Target % | 1.5% | Take-profit per trade |
| Stop % | 0.8% | Stop-loss per trade |
| Trend Filter | on | Only take trades aligned with EMA trend |
| Fresh Start | off | Reset portfolio to starting capital on session start |
- The session runs from 09:15 to 15:30 IST, Monday–Friday. All open positions are force-closed at 15:25.
- EOD charts and a P&L statement are generated at session end under
output/paper_trading/YYYY-MM-DD/. - Portfolio state is persisted to
~/.tech_analyzer/paper_portfolio.jsonand survives server restarts. - The Stop button interrupts the current inter-candle sleep immediately.