Online Trading
Exchange-Grade Platform Infrastructure
Full-stack brokerage trading platform: real-time price-time priority matching engine with async mutex locking, pre-trade risk gate (4-check), T+1 settlement engine, multi-asset instrument support (equities, derivatives, commodities), automated contract note generation, and full back-office OMS. 12 production modules.
Exchange-grade infrastructure. Custom-branded brokerage.
Off-the-shelf brokerage technology (white-labeled trading terminals) limits a brokerage's ability to differentiate on UX, product features, or instrument offerings. Arivu built a fully custom trading platform - with a proprietary matching engine, risk management system, and back-office OMS - giving the client complete technology ownership and the flexibility to build features their competitors can't replicate.
Technology Ownership
Custom-built platform vs. white-labeled terminal - complete code ownership, full feature control.
Real-Time Infrastructure
Sub-50ms order book WebSocket broadcast. Async mutex-protected matching engine for race-free order processing.
SEBI Compliance Built-In
T+1 settlement, upfront margin enforcement, contract note generation, and surveillance features built into the platform.
Price-time priority. Mutex-protected. Sub-50ms.
The central order book maintains two sorted priority queues - bids in descending price order, asks in ascending price order. When a new order arrives, an async mutex lock is acquired before any modification, preventing race conditions in concurrent order submission scenarios.
Price-Time Priority
At the same price level, the order that arrived first is matched first. FIFO queue per price level.
Async Mutex Lock
Every order that modifies the book acquires an exclusive mutex lock - preventing two concurrent orders from simultaneously corrupting queue state.
Execution Report
On match, a trade execution report is generated: trade ID, price, quantity, buyer/seller IDs, timestamp. Sent to both counterparties via WebSocket.
Market Order Slippage Protection
Market orders execute against available liquidity in price-time order. If available quantity is insufficient, the remainder is cancelled (IOC) or converted to a limit order (configurable).
Production-grade fintech engineering stack.
Real production code from the trading platform.
The central order book maintains sorted bid and ask price queues. WebSocket broadcasts state changes to all subscribed clients within 50ms. Critical section locked with async mutex to prevent race conditions in high-frequency environments.
1import { Mutex } from "async-mutex";23interface Order { id: string; price: number; quantity: number; side: "BID" | "ASK"; userId: string; }45class OrderBook {6 private bids: Order[] = []; // Sorted high to low7 private asks: Order[] = []; // Sorted low to high8 private mutex = new Mutex();910 async addOrder(order: Order): Promise<Trade[]> {11 const release = await this.mutex.acquire();12 try {13 const trades = this.match(order); // Try to match incoming order14 if (order.side === "BID") {15 this.bids = [...this.bids, order].sort((a, b) => b.price - a.price);16 } else {17 this.asks = [...this.asks, order].sort((a, b) => a.price - b.price);18 }19 broadcastOrderBook({ bids: this.bids, asks: this.asks });20 return trades;21 } finally {22 release(); // Always release mutex23 }24 }2526 private match(incoming: Order): Trade[] { /* Price-time priority matching */ }27}4-gate pre-trade risk check. No order bypasses it.
Available Margin Check
INSUFFICIENT_MARGINRequired margin calculated as: order value × SEBI-mandated margin rate per instrument/segment. Order rejected if account's available margin balance is insufficient. Prevents over-leveraged positions.
Open Position Limit
POSITION_LIMIT_EXCEEDEDMaximum open position size per symbol enforced by the brokerage. Configurable per account tier and per instrument. Prevents concentration risk in a single name.
Daily Loss Limit (Drawdown Stop)
DAILY_LOSS_LIMIT_BREACHRunning daily P&L monitored against account's pre-configured daily loss limit. Order rejected once limit is breached. Protects client from runaway intraday losses.
Concentration Limit
CONCENTRATION_LIMITSingle instrument's exposure as a % of portfolio value checked against maximum concentration limit. Prevents position so large in a single name that a halt or circuit breaker creates margin call contagion.
Every module, documented.
Matching Engine & Order Book
Real-time order book with price-time priority matching. Bid and ask queues with async mutex lock for race condition protection. WebSocket broadcast of order book state within 50ms of order submission. Supports limit orders, market orders, and stop-loss orders.
SEBI T+1 settlement. Atomic transactions.
SEBI mandated T+1 settlement for all equity trades from January 2023. The settlement engine runs at market close, netting positions and committing all ledger changes in atomic database transactions - all-or-nothing.
Market Close
Trading day concludes. No new orders accepted. Order book frozen for settlement processing.
Net Position Calculation
Buy and sell transactions in the same instrument for the same client netted - only the difference settles (efficient capital use).
Funds Settlement (SEBI T+1)
Ledger credit to sellers, debit to buyers executed in atomic DB transactions. Failure triggers rollback - no partial settlement.
Securities Settlement
Positions table updated: seller positions decremented, buyer positions incremented. CDSL/NSDL demat account instructions dispatched.
Confirmation Dispatch
Settlement confirmation contract notes emailed to all traders. Positions and cash balances available for next trading session.
TradingView-compatible. 15+ indicators.
- Candlestick (OHLCV)
- Line (Close)
- Heikin-Ashi
- Hollow Candlestick
- 1m, 3m, 5m, 15m, 30m
- 1H, 2H, 4H
- 1D, 1W, 1M
- SMA (Simple Moving Avg)
- EMA (Exponential MA)
- VWAP
- Bollinger Bands
- RSI (14/21 period)
- MACD (12,26,9)
- Stochastic Oscillator
- CCI
- ATR (Average True Range)
- Bollinger Band Width
- Keltner Channel
- OBV (On-Balance Volume)
- Volume Profile
- VWAP bands
- CMF (Chaikin MF)
SEBI-compliant KYC. Fully digital.
Mobile OTP Verification
Phone number verified via OTP. Account pre-registration created. Session token issued.
Aadhaar OTP eKYC
Aadhaar number entered. OTP sent to Aadhaar-linked mobile. On success: name, date of birth, and address auto-populated from UIDAI response.
PAN Card Verification
PAN number verified against ITD API. Name matching against Aadhaar. PAN linked to account as the primary tax identifier.
Bank Account Linkage (Penny Drop)
Account holder enters bank account number and IFSC. Penny drop initiated: ₹1 deposited to verify account is valid and belongs to the registered person.
Demat Account Linkage (CDSL/NSDL)
BO ID (8-digit beneficiary owner ID) or 16-digit demat account number linked to the trading account for securities settlement.
Risk Profiling
Mandatory SEBI-prescribed risk profiling questionnaire. Output: Conservative / Moderate / Aggressive. Determines permitted segments (equity cash, F&O, commodity).
Regulatory compliance, engineered in.
T+1 Settlement Mandate
T+1 settlement engine built to SEBI's mandate for all equity trades from January 2023. Settlement runs as EOD batch job.
Upfront Margin Collection
SEBI requires upfront margin before order placement. Risk engine enforces this - no order clears the book without validated margin.
Contract Note Generation
Auto-generated PDF contract notes on every trade execution - legally required document per SEBI ICDR. Emailed within market hours.
Audit Trail (Immutable Log)
Append-only event log captures every order state transition: Placed → Partially Filled → Filled → Cancelled. Regulatorily required.
Surveillance Alerts
Concentration alerts, wash trade pattern detection, rapid order sequence flags. Compliance desk dashboard for manual review.
NRI & Corporate Accounts
NRI account type support (PINS/non-PINS), corporate account KYC (MCA21 lookup), HUF account structure. All SEBI-permitted account types.
Trading platform schema.
Partitioned orders table for high-volume trade history. Separate immutable event_log table for regulatory audit trail.