Solid Risk Checks
16 institutional safety controls protecting your trading capital before any order reaches the exchange.
Price Range & Circuit Limit Check (LC / UC)
Upper & Lower Exchange Price Band EnforcerVerifies in real time that every dispatched order price falls strictly within the exchange Lower Circuit (LC) and Upper Circuit (UC) limits.
Prior to order transmission, the bot queries the broker live security master and market depth for the day’s dynamic circuit limits. If the intended limit price is below LC or above UC, the order is blocked immediately.
Freak Trade Spike: In an illiquid strike, an unhedged order fires at ₹300 instead of ₹30, executing against a market maker spike and causing instantaneous capital wipeout.
Single Order Max Quantity Limit
Single Transaction Max Lot / Quantity CeilingHard ceiling on the maximum lots or shares allowed in any single order transaction.
The middleware validates the requested order quantity against a pre-configured maximum lot cap per instrument (e.g. Max 360 quantity in NIFTY). Any order exceeding the threshold is split into discrete slices or aborted.
Fat-Finger Execution: A script bug calculates 1,000 lots instead of 10 lots due to an unhandled decimal shift, instantly demanding ₹1.5 Crore in margin and locking the trading terminal.
Maximum Single Order Value Check
Gross Order Exposure Rupee CapLimits the gross rupee turnover (Price × Quantity) permissible for any individual trade.
Calculates the gross notional rupee exposure of the incoming order before dispatch. If order_value > MAX_ORDER_VALUE (e.g. ₹5,00,000), the execution pipeline raises an immediate block.
Index Option Squeeze: Buying deep ITM options during an unexpected gap-down results in an unintentional single order commitment exceeding total account net worth.
Cumulative Daily Traded Value Limit
Total Intraday Turnover AccumulatorTracks the running sum of all executed trades throughout the trading day against a predetermined daily ceiling.
A thread-safe persistent accumulator logs every filled order turnover. Once the cumulative sum plus the new order surpasses the daily turnover limit, no further orders can enter the market.
Brokerage Drain: A high-frequency whipsaw strategy generates ₹2 Crore in daily turnover on a ₹2 Lakh account, wiping out 25% of account equity in exchange transaction fees and STT alone.
Cumulative Daily Quantity Limit
Total Intraday Gross Lot CeilingCaps the absolute gross number of contracts or shares traded in a single trading session.
Maintains an atomic count of total lots executed since 09:15 IST. If gross volume exceeds the authorized daily limit, new orders are blocked.
Overtrading Spiral: An oscillating indicator triggers 150 times in 2 hours during a narrow range, accumulating thousands of unnecessary contracts and depleting capital.
Net Open Position Limit
Net Directional Open Position SafeguardStrictly monitors total open directional contracts (Buy Lots - Sell Lots) in any given strike or underlying.
The middleware interrogates the live broker position book before order placement to calculate directional delta exposure. It halts orders that would elevate open exposure beyond the predefined limit.
Runaway Delta Exposure: An algorithm intended to hold only 2 lots accidentally buys 10 lots due to missing position book synchronization, subjecting the account to massive overnight margin calls.
Runaway Loop Detector & Panic Kill-Switch
High-Frequency Order Loop Circuit BreakerDetects infinite algorithmic loops and automatically disengages the system if more than 5 orders are attempted within 1 second.
Uses a sliding time-window rate limiter. If >5 order requests occur inside a 1,000ms window, the middleware trips the hardware circuit breaker, cancels pending orders, and alerts the admin via Telegram.
The Infinite Loop Disaster: A coding error while waiting for a fill continuously issues buy orders in a while-loop. Within 10 seconds, 250 orders flood the exchange, exhausting the account balance and triggering a broker IP block.
Anti-Duplicate Order & Unique clOrdID Verification
Cryptographic clOrdID Duplicate FilterGenerates a collision-resistant UUID for every trade intent, preventing network retry duplicates.
Every order intent receives a unique cryptographic identifier (clOrdID). The state engine keeps a 24-hour memory cache. If a webhook or signal retries with the same ID, it is identified as a duplicate and dismissed.
Double Fill on Slow Internet: A TradingView webhook retries after a 2-second cloud timeout. Both orders execute on the broker, leaving the trader with 2x intended position size without their knowledge.
Market Order Blocker (Limit-Only Execution)
Market Order Prevention & Slippage GuardBlocks raw market orders in F&O options, forcing the use of Marketable Limit Orders with predefined slippage guards.
The middleware intercepts any order marked as ORDER_TYPE_MARKET in option contracts and converts it to a LIMIT order at (Ask Price + 1.5% slippage buffer), preventing execution against empty order books.
The 100-Point Freak Fill: Placing a market order to buy a ₹15 option during an index expiry candle fills at ₹95 because the nearest ask in the depth was placed by an arbitrage bot 80 points higher.
Symbol Whitelisting & Expiry Verification
Authorized Instrument & Expiry Cycle ValidatorEnsures the bot only trades verified, authorized instruments matching the current active expiry cycle.
Orders are validated against an explicit whitelist of symbols and active expiry master tables. Any ticker string that does not strictly match approved instruments is immediately discarded.
The Wrong Expiry Trap: An automated script intended to trade the weekly expiry accidentally trades the monthly expiry with 50-point wider bid-ask spreads, instantly losing ₹20,000 on execution entry.
Self-Trade Prevention Filter
Opposing Book Self-Execution FilterPrevents the bot from issuing a buy order that could match against an existing open sell order in the same trading account.
The order dispatcher inspects the active order book. If an opposite-side pending order exists for the identical strike and price, the new order is rejected until the pending order is cancelled.
Exchange Surveillance Penalty: A multi-strategy account buys and sells the same option strike at the same second. The exchange flags this as wash trading and imposes an automated compliance penalty.
Pre-Trade Margin Verification with 5% Safety Buffer
Real-Time Margin Check with 5% BufferVerifies available trading cash against exchange margin requirements, maintaining an extra 5% cash buffer before order dispatch.
Queries the broker margin calculator API for the specific basket or single leg. Compares against free cash. If (Required Margin × 1.05) > Available Cash, the trade is rejected.
Peak Margin Shortfall Penalty: Option selling strategy shorts 4 lots with exactly ₹4,00,000 in account. Spiking IV increases intraday margin requirement to ₹4,15,000, triggering a 1% SEBI margin penalty.
Global Emergency Kill Switch
Emergency Position Liquidation & System LockInstant single-trigger emergency shutdown mechanism accessible via Telegram, Web UI, or automated exception handlers.
When triggered, the kill switch executes a 3-step atomic sequence: (1) Cancels all open/pending orders, (2) Squares off all open positions at marketable limit prices, and (3) Locks out the execution thread.
Black Swan Market Crash: Sudden war declaration causes a 1,000-point gap down during market hours. With no automated kill switch, the strategy continues attempting to buy dip signals, taking immense damage.
API Rate Limiting & Queue Throttling (0.2s Pacing)
Outbound Queue Rate Limiter (200ms Pacing)Paces all outbound broker API calls through an asynchronous queue with a mandatory 200ms spacing to comply with broker QPS limits.
All order payloads enter a priority queue. A background token-bucket throttler pops orders at maximum 5 requests per second, ensuring zero HTTP 429 (Too Many Requests) broker errors.
API Key Ban during Market High: Bot submits 12 orders simultaneously for a multi-leg basket. The broker responds with HTTP 429 and suspends the API session for 15 minutes right when a stop-loss needs to execute.
Strict Market Session & Time Window Check
NTP Time-Synced Session Window GuardEnsures no new trades are placed before 09:15:00 IST or after 15:30:00 IST, with automated intraday square-off at 15:15:00 IST.
The middleware clock synchronizes with NTP Indian Standard Time. New entries are permitted only between 09:15:30 and 15:05:00. At 15:15:00 sharp, the intraday square-off handler executes automatically.
Broker Auto-Squareoff Surcharge: 10 unclosed intraday option legs carry past 15:20 IST. Broker RMS closes them at unfavorable prices and charges ₹590 in RMS penalty fees.
User Authentication & Daily TOTP Token Health Check
Automated 2FA / TOTP Health DaemonValidates broker session health and API tokens continuously, executing automatic background daily TOTP logins before market open.
Runs a background daemon at 08:45 AM IST that automatically performs TOTP authentication and refreshes the JWT access token. Performs a lightweight heartbeat check before every trade.
Expired Session at 09:20 AM: Strategy attempts to short straddle at 09:20 AM, but the broker session expired overnight. Orders fail silently, and the trader misses the entire move of the day.
Ready to Build Your Bot?
Every client bot we develop includes this complete risk harness by default. Share your strategy conditions with our engineering team for a free scope review and fixed quotation.
