SYSTEM ARCHITECTURE Β· REAL-TIME EXECUTION PIPELINE

How the Engine Works

From encrypted broker OAuth and live WebSocket tick ingestion to the 6-stage quantitative decision pipeline and post-entry risk enforcement across NSE, BSE, F&O stocks, and MCX commodities.

Sub-Second Tick Processing Multi-Segment Support AES BYOK Vault Dedicated Egress IP

1. The 6-Stage Execution Pipeline

Whether you run in Analyze Only, forward-test in Paper Mode, or execute in Live Mode, every trade passes through an identical deterministic 6-stage pipeline:

01
Universe Resolution & Expiry Selection

Resolves the active underlying asset (NIFTY, BANKNIFTY, FINNIFTY, MIDCPNIFTY, SENSEX, F&O equities, or CRUDEOIL/NATURALGAS). Automatically detects strike interval (50, 100, 25, 20 pts), locates the nearest active expiry, isolates the ATM ±5 strike chain (11 CALL and 11 PUT instruments), and establishes WebSocket subscriptions.

02
Market Telemetry & Micro-Structure Backfill

Samples live spot quote and candle feeds to establish the session open, computes true session VWAP, locks the 15-Minute Opening Range (09:15–09:30 IST), pulls the live India VIX quote, and calculates 15-day historical open-to-close index ranges.

03
Option Chain Matrix & AI Synthesis

Queries open interest across the 11 strikes, applies inverse-distance proximity weights, measures fresh intraday OI build-up vs unwinding, evaluates weighted PCR, and formats segment-aware macro context for Google Gemini or Anthropic Claude. Synthesizes an explicit 0–100% Upside Probability.

04
Profitability & Risk Gate Verification

Compares today’s blended expected move against ATM option premium breakeven (× 1.15x margin factor). Verifies daily maximum loss circuit breaker, checks maximum trades per day, applies VIX-based lot scaling, and confirms momentum exhaustion bounds before authorizing a decision (CALL, PUT, BOTH, or NO_TRADE).

05
Order Dispatch (Paper Simulation or Live Broker)

In Paper Mode, records virtual fills at exact live market LTP and streams live simulated P&L to the terminal and 30-day CSV journal. In Live Mode, dispatches market BUY orders via Zerodha Kite Connect v3 or Alice Blue ANT v2 using the trader's encrypted session token.

06
Post-Entry Tick Loop & Automated Square-Off

Enters an asynchronous monitoring loop processing live WebSocket ticks. Enforces combined or individual leg stop-loss, profit targets, trailing stop-loss, manual exit, or mandatory 15:15 IST Force Square-Off.

2. System Architecture & Data Flow

ExcelAlgoTrader is structured around high-throughput, low-latency microservices ensuring strict multi-tenant isolation, memory safety, and zero downtime across broker reconnections:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          HTTPS & WebSocket (WSS)         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Client Browser / Trading UI        β”‚  <=====================================> β”‚      Python Flask + Gevent / Sockets    β”‚
β”‚  β€’ Lightweight Charts (Live Canvas)    β”‚           Tenant-Isolated Room           β”‚  β€’ Dynamic Multi-Tenant Routing        β”‚
β”‚  β€’ Signal Chips & Probability Gauges   β”‚                                          β”‚  β€’ Socket.IO Real-Time Relays          β”‚
β”‚  β€’ Manual Execution & Exit Triggers    β”‚                                          β”‚  β€’ Admin Control & Telemetry Analytics β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                                                        β”‚
                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β–Ό                                                                β–Ό                                                                β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚     Encrypted SaaS Cloud Vault    β”‚                            β”‚    Quantitative Decision Engine   β”‚                            β”‚    Broker & Exchange Connectivity β”‚
                     β”‚  β€’ Fernet AES-256 UserSecrets     β”‚                            β”‚  β€’ Multi-Segment Strike Discovery β”‚                            β”‚  β€’ Zerodha Kite Connect v3        β”‚
                     β”‚  β€’ Daily BrokerSession Tokens     β”‚ <------------------------> β”‚  β€’ 7-Factor Probability Matrix    β”‚ <------------------------> β”‚  β€’ Alice Blue ANT v2 (WebSocket)  β”‚
                     β”‚  β€’ PaperTradeRow & Trade Journal  β”‚                            β”‚  β€’ Expected Move / VIX Range Gate β”‚                            β”‚  β€’ Multi-Asset Gemini/Claude AI   β”‚
                     β”‚  β€’ Plan Quotas & Online Heartbeat β”‚                            β”‚  β€’ Trailing SL / 15:15 Auto Exit  β”‚                            β”‚  β€’ Static Egress IP Whitelisting  β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      

3. Cloud Security & Bring-Your-Own-Key (BYOK)

Unlike traditional black-box platforms that store plain-text API secrets on centralized servers, ExcelAlgoTrader enforces strict client-side encryption and isolation:

  • Master Key AES-256 Encryption: Your Zerodha API Key, API Secret, or Alice Blue App Code and secrets are encrypted immediately upon entry using a cryptographically randomized MASTER_ENCRYPTION_KEY via Fernet symmetric encryption.
  • Zero-Storage Access Tokens: Daily broker OAuth access tokens exist only within the ephemeral memory of your isolated tenant worker and encrypted cache for the trading day, expiring automatically upon session teardown.
  • Static Server Egress IP Whitelisting: Zerodha Kite Connect may require a static public egress IP for live order execution. For a self-hosted deployment, obtain the outbound IP assigned to your trading server from your hosting provider or server administrator, then register that IP in your Kite Developer App. A personal computer or home-network IP is not a substitute.
  • Session Persistence Across Server Restarts: If the production server restarts during market hours, your authenticated broker session is automatically recovered without requiring re-login, seamlessly re-establishing WebSocket feeds and position monitoring.

4. Intraday Market Session Timeline

The trading terminal synchronizes automatically with official exchange trading schedules across all segments:

Time (IST) Market Event Engine State & Automated Action
09:00 – 09:08 Exchange Pre-Open Session Computes overnight opening gaps, queries global cues, and primes multi-asset AI context.
09:15 Market Open (Equity & F&O) WebSocket connection initiates; streams live index spot LTP, ATM ±5 strike chain quotes, and session VWAP.
09:15 – 09:30 Opening Range Formation Tracks high and low of the initial 15-minute window (orb_minutes = 15). Breakout bonuses are armed.
09:30 – 15:00 Prime Execution Window Optimal algorithmic entry window. Full probability models, momentum exhaustion bands, and risk gates are active.
15:15 Intraday Force Square-Off Mandatory auto square-off executes at market price for all open positions. No intraday trades held overnight.
15:30 Cash & F&O Market Close Equity sessions close. MCX commodity monitoring continues active until 23:30 / 23:55 IST.
Post-Market Idle Spot Watchdog Sleep Idle spot polling automatically pauses to eliminate CPU and API quota waste when markets are closed.