Arivu Technologies
FINTECH - TRADING PLATFORM INFRASTRUCTURE12 Modules

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.

PLATFORM LIVE SPEC
Matching EnginePrice-time priority + async mutex
Order TypesLimit, Market, Stop-Loss, IOC, GTT
Order Book Latency<50ms WebSocket broadcast
Risk Engine4-check pre-trade gate (margin + limits)
SettlementT+1 SEBI-compliant EOD engine
InstrumentsEquities, Derivatives, Commodities, Bonds
KYCAadhaar OTP + PAN + bank penny drop
Charting15+ technical indicators, 1m–1M intervals
01 / PLATFORM CONTEXT

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.

<50ms
Order book WebSocket broadcast latency
4 Checks
Pre-trade risk gate before order book
T+1
SEBI-compliant settlement engine
12 Modules
From matching engine to mobile app
02 / MATCHING ENGINE ARCHITECTURE

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.

Order Processing Flow
1. Order received via REST API or FIX gateway
2. Pre-trade risk check (4-gate validation)
3. Async mutex.acquire() - lock order book
4. Try to match: best bid vs. best ask
5. If match: create Trade, emit execution report
6. If no match: append to bids/asks queue
7. Broadcast updated book via WebSocket
8. mutex.release() - unlock for next order

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

03 / TECHNOLOGY STACK

Production-grade fintech engineering stack.

LayerTechnologyPurpose
Matching EngineNode.js (async-mutex + TypeScript)Price-time priority order book, mutex-locked concurrent safety
Real-Time DataWebSocket (ws library) + Redis Pub/SubSub-50ms order book broadcast to all connected clients
Trading APIREST + FIX Protocol adapterOrder submission, modification, cancellation endpoints
Risk EngineTypeScript middleware (synchronous pre-check)4-gate pre-trade risk validation before order book
DatabasePostgreSQL 16 (partitioned trades table)Order ledger, trade history, settlement records, positions
SettlementNode.js cron + DB transactionsT+1 EOD settlement engine with atomic ledger updates
FrontendNext.js + Lightweight Charts (TradingView)Trading terminal UI, order book depth display, charting
KYCAadhaar OTP (Sandbox API) + PAN verifyIdentity verification, account activation workflow
MobileReact Native (Expo)Mobile trading app with push notifications for fills
Audit TrailAppend-only immutable event log (PostgreSQL)Regulatorily-required complete audit of all order events
04 / INSPECTABLE CODE

Real production code from the trading platform.

trading/orderbook.ts

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";
2
3interface Order { id: string; price: number; quantity: number; side: "BID" | "ASK"; userId: string; }
4
5class OrderBook {
6 private bids: Order[] = []; // Sorted high to low
7 private asks: Order[] = []; // Sorted low to high
8 private mutex = new Mutex();
9
10 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 order
14 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 mutex
23 }
24 }
25
26 private match(incoming: Order): Trade[] { /* Price-time priority matching */ }
27}
05 / RISK MANAGEMENT SYSTEM

4-gate pre-trade risk check. No order bypasses it.

Available Margin Check

INSUFFICIENT_MARGIN

Required 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_EXCEEDED

Maximum 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_BREACH

Running 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_LIMIT

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

06 / 12-MODULE EXPLORER

Every module, documented.

MODULE 01

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.

07 / T+1 SETTLEMENT ENGINE

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.

18:00

Market Close

Trading day concludes. No new orders accepted. Order book frozen for settlement processing.

EOD

Net Position Calculation

Buy and sell transactions in the same instrument for the same client netted - only the difference settles (efficient capital use).

EOD+1

Funds Settlement (SEBI T+1)

Ledger credit to sellers, debit to buyers executed in atomic DB transactions. Failure triggers rollback - no partial settlement.

EOD+1

Securities Settlement

Positions table updated: seller positions decremented, buyer positions incremented. CDSL/NSDL demat account instructions dispatched.

T+1 AM

Confirmation Dispatch

Settlement confirmation contract notes emailed to all traders. Positions and cash balances available for next trading session.

08 / CHARTING & TECHNICAL ANALYSIS

TradingView-compatible. 15+ indicators.

Chart Types
  • Candlestick (OHLCV)
  • Line (Close)
  • Heikin-Ashi
  • Hollow Candlestick
Time Intervals
  • 1m, 3m, 5m, 15m, 30m
  • 1H, 2H, 4H
  • 1D, 1W, 1M
Trend Indicators
  • SMA (Simple Moving Avg)
  • EMA (Exponential MA)
  • VWAP
  • Bollinger Bands
Momentum
  • RSI (14/21 period)
  • MACD (12,26,9)
  • Stochastic Oscillator
  • CCI
Volatility
  • ATR (Average True Range)
  • Bollinger Band Width
  • Keltner Channel
Volume
  • OBV (On-Balance Volume)
  • Volume Profile
  • VWAP bands
  • CMF (Chaikin MF)
09 / KYC & ACCOUNT ONBOARDING

SEBI-compliant KYC. Fully digital.

01

Mobile OTP Verification

Phone number verified via OTP. Account pre-registration created. Session token issued.

02

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.

03

PAN Card Verification

PAN number verified against ITD API. Name matching against Aadhaar. PAN linked to account as the primary tax identifier.

04

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.

05

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.

06

Risk Profiling

Mandatory SEBI-prescribed risk profiling questionnaire. Output: Conservative / Moderate / Aggressive. Determines permitted segments (equity cash, F&O, commodity).

10 / SEBI COMPLIANCE FEATURES

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.

11 / DATA MODEL

Trading platform schema.

Partitioned orders table for high-volume trade history. Separate immutable event_log table for regulatory audit trail.

accountsAccount master
id, user_id, account_type, kyc_status, segment_permissions, daily_loss_limit, created_at
ordersOrder ledger (partitioned)
id, account_id, symbol, side, order_type, price, quantity, filled_qty, status, placed_at (PARTITIONED BY month)
tradesExecuted trades
id, buy_order_id, sell_order_id, symbol, price, quantity, total_value, trade_time, settlement_date
positionsOpen positions
account_id, symbol, qty, avg_cost_price, realized_pnl, unrealized_pnl
ledgerCash ledger
id, account_id, type (CREDIT/DEBIT), amount, balance_after, ref_id, created_at
event_logImmutable audit trail
id, entity_type, entity_id, event_type, payload, created_at (APPEND-ONLY)
12 / FAQs

Questions about the trading platform?

Who is the Online Trading Platform built for?

How does the matching engine ensure price-time priority?

What SEBI compliance features are built in?

What are the source files for this project?

ARIVU FINTECH ENGINEERING · BENGALURU

Build your brokerage on custom-built infrastructure.

Arivu engineers custom trading platforms for stockbrokerages, commodity platforms, and investment firms. Contact our fintech team in Bengaluru to scope your trading infrastructure.