Automated NIFTY50 Options Trading bot based on Global sentiment, institutional flows, and real-time technical indicators.
The current version is a fully browser-based automated trading system for Nifty weekly options. It runs as a React dashboard backed by a Cloudflare Worker proxy and a D1 database for persistence. Order execution and tracking are fully automated via the Upstox API.
- 5-Layer Scoring Engine: Combines macro sentiments, technical indicators, and institutional flow into a single unified bullish/bearish score.
- Web Dashboard: Modern UI available at
app/clientto control the bot, configure strategies, view signals, and manage positions. - D1 Persistence: Safely persists broker accounts and strategy configuration via a Cloudflare Worker backed by a SQLite D1 database.
- State Machine Polling: Robust state management (
IDLE➔RUNNING➔ORDERED➔RUNNING/STOPPED) polling every 60s. - Automated Exit Logic: Triggered automatically on target profit/loss, indicator/macro reversals, or index breadth flips.
For complete details on the strategy rules, see docs/v5-strategy.md.
To run the browser dashboard locally and deploy its backend:
- Navigate to the client directory:
cd app/client - Install the required dependencies:
yarn install
- Apply D1 migrations to set up the persistence database locally:
yarn wrangler d1 migrations apply algo-trade-paper --local
- Run the development server:
yarn dev
- (Optional) Apply migrations to your remote Cloudflare database and deploy the Worker:
yarn wrangler d1 migrations apply algo-trade-paper --remote yarn deploy
For detailed client setup and migration steps, refer to app/client/README.md and docs/client-persistence.md.
If you wish to run the legacy CLI/console versions (V1–V4):
- Navigate to the core directory:
cd app/core - Install dependencies:
yarn install # or npm install - Create a
.envfile and configure your broker credentials. Use.env.sampleas a template. - Compile the TypeScript code:
tsc
- Start the console job:
yarn start # or npm run start
Browser Tab (React + Vite)
│
├─ useStrategyBot.ts ← State machine, 60s polling loop
│ ├─ fetchMarket() ← Candles + Option Chain + Macro signals
│ └─ fetchMarketSentiment() ← VIX, FII, DII, PCR, Max Pain + synthetic MMI/PE/IV
│
├─ strategyEngine.ts ← 5-layer scoring → FinalSignal
│ ├─ scoreBullish() ← BUY CE score (max ~27 pts)
│ └─ scoreBearish() ← BUY PE score (max ~26 pts)
│
├─ Cloudflare Worker ← CORS proxy for all external APIs
│ ├─ Upstox API ← Candles, option chain, FII/DII, VIX, place/exit orders
│ └─ MoneyControl API ← Global indices technical ratings
│
└─ UI (strategies page)
├─ MarketSetupPanel ← VIX, FII %, Nifty PE, MMI
├─ InstitutionalPanel ← MMI gauge, FII scores
├─ BreadthPanel ← A/D ratio, PCR zone, Straddle IV
├─ IndicatorsPanel ← 6 technical indicator cards
├─ ScorePanel ← Bull/bear score bars + final signal
├─ BotControls ← Start/Stop, position card, countdown
└─ StrategyConfig ← Config form with localStorage
| Layer | Source | Signal & Description |
|---|---|---|
| L0: Hard Stops | Upstox VIX | Blocks trading completely if VIX is out of bounds (< 10 or > 25). Nifty PE is synthetic and penalises score only. |
| L1: Macro | MoneyControl + Upstox breadth | Evaluates global index sentiment (Dow, Nikkei, Hang Seng, FTSE, etc.), Advance/Decline ratios, and Put-Call Ratio (PCR). |
| L2: Technicals | Upstox 1-min candles | Real-time indicators: EMA crossover (10/42), ADX, RSI, Stochastic, Bollinger Bands, and ATR. |
| L3: Institutional | Upstox FII/DII API + synthetic computation | Institutional flow: MMI (synthetic), FII Long/Short ratio (bull contrarian + bear momentum), Net Positioning, Straddle IV vs VIX. |
| L4: Confluence Gate | Unified Evaluator | Enforces minimum score gap (bull vs bear) and overall score threshold to generate entry signals. |
These parameters can be customized dynamically from the dashboard UI:
- Confidence Thresholds: Customize minimum scores for both
moderateandstrongsignals. - Profit & Loss Limits: Set trailing or absolute targets for automatic position exits.
- Max Trades Per Day: Protect your account by limiting over-trading.
- Last Entry Time: Restrict bot entry signals past a set time (e.g., 14:30 IST).
- Strike Offset (OTM Skip): Configurable offset to purchase out-of-the-money options (default: 3 strikes OTM).
- V5 (Latest): React Dashboard with Cloudflare Worker proxy, D1 schema storage, and multi-layer scoring engine.
- V4 (In Dev / Console): Integrates technical indicators directly from Upstox 1-min candles (EMA crossover, ADX, RSI, Stochastic, Bollinger Bands, ATR).
- V3: Consolidated macro sentiment fetches from MoneyControl and NSE India, placing orders via Upstox.
- V2: Scraped Investing.com for global trends and 1-min indicators, executed trades via Finvasia.
- V1: Basic Investing.com scraper with 5-min/1-min trend checks and ATR/RSI, trading via Finvasia.
We welcome contributions! If you would like to collaborate:
- Connect with me on LinkedIn: itaravin
- Submit issues or feature requests: GitHub Issues



