Algoh
Pre-Trade Capital Protection

Solid Risk Checks

16 institutional safety controls protecting your trading capital before any order reaches the exchange.

16Pre-Trade Checks
< 2msCheck Latency
100%SEBI Aligned
0Loop Errors
Check #1Price & Capital
Included in All Bots

Price Range & Circuit Limit Check (LC / UC)

Upper & Lower Exchange Price Band Enforcer

Verifies in real time that every dispatched order price falls strictly within the exchange Lower Circuit (LC) and Upper Circuit (UC) limits.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #2Price & Capital
Included in All Bots

Single Order Max Quantity Limit

Single Transaction Max Lot / Quantity Ceiling

Hard ceiling on the maximum lots or shares allowed in any single order transaction.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #3Price & Capital
Included in All Bots

Maximum Single Order Value Check

Gross Order Exposure Rupee Cap

Limits the gross rupee turnover (Price × Quantity) permissible for any individual trade.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

Index Option Squeeze: Buying deep ITM options during an unexpected gap-down results in an unintentional single order commitment exceeding total account net worth.

Check #4Price & Capital
Included in All Bots

Cumulative Daily Traded Value Limit

Total Intraday Turnover Accumulator

Tracks the running sum of all executed trades throughout the trading day against a predetermined daily ceiling.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #5Price & Capital
Included in All Bots

Cumulative Daily Quantity Limit

Total Intraday Gross Lot Ceiling

Caps the absolute gross number of contracts or shares traded in a single trading session.

Why It Matters (Benefit):

Maintains an atomic count of total lots executed since 09:15 IST. If gross volume exceeds the authorized daily limit, new orders are blocked.

Risk If Missing (Damage):

Overtrading Spiral: An oscillating indicator triggers 150 times in 2 hours during a narrow range, accumulating thousands of unnecessary contracts and depleting capital.

Check #6Price & Capital
Included in All Bots

Net Open Position Limit

Net Directional Open Position Safeguard

Strictly monitors total open directional contracts (Buy Lots - Sell Lots) in any given strike or underlying.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #7Order Integrity
Included in All Bots

Runaway Loop Detector & Panic Kill-Switch

High-Frequency Order Loop Circuit Breaker

Detects infinite algorithmic loops and automatically disengages the system if more than 5 orders are attempted within 1 second.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #8Order Integrity
Included in All Bots

Anti-Duplicate Order & Unique clOrdID Verification

Cryptographic clOrdID Duplicate Filter

Generates a collision-resistant UUID for every trade intent, preventing network retry duplicates.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #9Order Integrity
Included in All Bots

Market Order Blocker (Limit-Only Execution)

Market Order Prevention & Slippage Guard

Blocks raw market orders in F&O options, forcing the use of Marketable Limit Orders with predefined slippage guards.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #10Order Integrity
Included in All Bots

Symbol Whitelisting & Expiry Verification

Authorized Instrument & Expiry Cycle Validator

Ensures the bot only trades verified, authorized instruments matching the current active expiry cycle.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #11Order Integrity
Included in All Bots

Self-Trade Prevention Filter

Opposing Book Self-Execution Filter

Prevents the bot from issuing a buy order that could match against an existing open sell order in the same trading account.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #12Price & Capital
Included in All Bots

Pre-Trade Margin Verification with 5% Safety Buffer

Real-Time Margin Check with 5% Buffer

Verifies available trading cash against exchange margin requirements, maintaining an extra 5% cash buffer before order dispatch.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #13System & Session
Included in All Bots

Global Emergency Kill Switch

Emergency Position Liquidation & System Lock

Instant single-trigger emergency shutdown mechanism accessible via Telegram, Web UI, or automated exception handlers.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #14System & Session
Included in All Bots

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.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #15System & Session
Included in All Bots

Strict Market Session & Time Window Check

NTP Time-Synced Session Window Guard

Ensures 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.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Check #16System & Session
Included in All Bots

User Authentication & Daily TOTP Token Health Check

Automated 2FA / TOTP Health Daemon

Validates broker session health and API tokens continuously, executing automatic background daily TOTP logins before market open.

Why It Matters (Benefit):

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.

Risk If Missing (Damage):

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.

Zero Compromise on Capital Protection

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.