Get Started — Overview

The Bridge Connector is a lightweight C-based communication layer that exposes two dedicated TCP sockets for client applications. One socket accepts inbound request strings (orders or commands) from clients; the other socket sends outbound responses (acknowledgements, execution reports, errors) back to the client. This interface is designed to be:

High-level Architecture

TCP
Client App
(sends strings)
-- Request Socket -->
Bridge Service
(C executable)
<-- Response Socket --

Key points

Features

Connection Details

Protocol: TCP
Default ports (example):

Address: Bind to 0.0.0.0 on the server for production, or 127.0.0.1 for local testing.
Message encoding: UTF-8 (recommended)
Message termination: \n (newline). All messages MUST be terminated by newline to allow proper framing.
Max message length: 4096 bytes (configurable)

REQUEST New Order

2000|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|0|202202241021|1|25|35|2|0.0|25|0
PosFieldDescription
12000New Order Request
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
100Order Id
11202202241021Echo Back Client reference
121Order Type Market / Limit
1325Order quantity
1435Order price
152Order action 1=Buy, 2=Sell
160.0SL trigger price
1725Total order quantity
180Remain quantity

REQUEST Modify Order

2040|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|404404480000101|202202241021|1|25|35|2|0.0|25|0
PosFieldDescription
12040Modify Request
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10404404480000101Order Id
11202202241021Echo Back Client reference
121Order type Market / Limit
1325Order quantity
1435Order price
152Order action 1=Buy, 2=Sell
160.0SL trigger price
1725Total order quantity
180Remain quantity

REQUEST Cancel Order

2070|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|404404480000101|202202241021|1|25|35|2|0.0|25|0
PosFieldDescription
12070Cancel Request
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10404404480000101Order Id
11202202241021Echo Back Client reference
121Order type Market / Limit
1325Order quantity
1435Order price
152Order action 1=Buy, 2=Sell
160.0SL trigger price
1725Total order quantity
180Remain quantity

RESPONSE Order Confirmation

2073|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|404404480000101|0|0|35.0000|202202241021|2|0|0|1330161808|1330161808|12345|123456789012345|25|25
PosFieldDescription
12073Order Confirmation
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10404404480000101Order Id
110Trade No
120Executed quantity
1335.0000Execution price
14202202241021Echo Back Client reference
1521=Buy, 2=Sell
160Error Code
170Reason Code
181330161808Exchange timestamp
191330161808Last modification time
2112345Participent (client id)
22123456789012345Term Ctcl
2325Remain quantity
2425Total original quantity

RESPONSE Modify Confirmation

2074|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|404404480000101|0|0|35.0000|202202241021|2|0|0|1330161808|1330161808|12345|123456789012345|25|25
PosFieldDescription
12074Order Modification Confirmation
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10404404480000101Order Id
110Trade No
120Executed quantity
1335.0000Execution price
14202202241021Echo Back Client reference
1521=Buy, 2=Sell
160Error Code
170Reason Code
181330161808Exchange timestamp
191330161808Last modification time
2112345Participent (client id)
22123456789012345Term Ctcl
2325Remain quantity
2425Total Original quantity

RESPONSE Cancel Confirmation

2075|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|404404480000101|0|0|35.0000|202202241021|2|0|0|1330161808|1330161808|12345|123456789012345|25|25
PosFieldDescription
12075Order Cancel Confirmation
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10404404480000101Order Id
110Trade No
120Executed quantity
1335.0000Execution price
14202202241021Echo Back Client reference
1521=Buy, 2=Sell
160Error Code
170Reason Code
181330161808Exchange timestamp
191330161808Last modification time
2012345Participent (client id)
21123456789012345Term Ctcl
2225Remain quantity
2325Total Original quantity

TRADE Trade Confirmation

2222|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|404404480000101|20046|25|35.0000|202202241021|2|0|0|1330161808|1330161808|12345|123456789012345|0|25
PosFieldDescription
12222Trade Confirmation
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10404404480000101Order Id
1120046Trade No
1225Executed quantity
1335.0000Execution price
14202202241021Echo Back Client reference
1521=Buy, 2=Sell
160Error Code
170Reason Code
181330161808Exchange timestamp
191330161808Last modification time
2012345Participent (client id)
21123456789012345Term Ctcl
220Remain quantity
2325Total Original quantity

REJECT Rejection

-9999|5|52166|BANKNIFTY|02/24/2022|OPTIDX|36200.00|CE|PRO|Rejected|0|0|35|202202241021|2|-1106|0|0|0|12345|123456789012345|0|25|Dealer TotalBuyValue M:50000.00 N:49300.50
PosFieldDescription
1-9999Rejection
25Exchange identifier
352166Instrument token
4BANKNIFTYTrading symbol
502/24/2022Contract expiry
6OPTIDXInstrument type
736200.00Option strike price
8CEOption Type
9PROTrading client
10RejectedOrder Id
110Trade No
120Executed quantity
1335Execution price
14202202241021Echo Back Client reference
1521=Buy, 2=Sell
16-1106Error Code
170Reason Code
180Exchange timestamp
190Last modification time
2012345Participent (client id)
21123456789012345Term Ctcl
220Remain quantity
2325Total Original quantity
23Dealer TotalBuyValue M:50000.00 N:49300.50Error Message

Broadcast Format

57439|NIFTY|5|03/03/2022|OPTIDX|PE|17400.00|50|76625|73550|150|73490|550|73930|50|73935|200|25400|0
PosFieldDescription
157439Token
2NIFTYScrip
35Exchange
403/03/2022Expiry_date
5OPTIDXInstrument
6CEOption Type
717000.00Strike price
850Last trade quantity
99165Last traded price
109150Bid price1
11900Bid quantity1
129145Bid price2
13500Bid quantity2
149170Ask price1
15400Ask quantity1
169175Ask price2
17900Ask quantity2
1853087000Total traded quantity
190Open interest

Socket Authentication

You MUST protect production sockets. Below are recommended options from simple to most secure.

Shared Secret (Simple)

Pros: Easy to implement.
Cons: Secret can be intercepted unless used with TLS.

Handshake example:
1. Server sends AUTH_REQUIRED\n
2. Client sends AUTH|<secret-key>\n
3. Server replies AUTH_OK\n or AUTH_FAIL\n

Heartbeat / Keepalive

Python Sample

Python Simple authenticated client connection
import socket HOST = "127.0.0.1" PORT = 5000 SECRET_KEY = "mysecret123" client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect((HOST, PORT)) # Receive AUTH request msg = client.recv(1024).decode() if msg == "AUTH:": client.send(SECRET_KEY.encode()) reply = client.recv(1024).decode() if reply != "AUTH_OK": print("Authentication failed") client.close() else: print("Authenticated!") # Continue sending/receiving client.send(b"Hello server") print(client.recv(1024).decode()) client.close()
Server Connections
import socket HOST = "0.0.0.0" PORT = 5000 SECRET_KEY = "mysecret123" # shared key server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind((HOST, PORT)) server.listen() print("Server running...") conn, addr = server.accept() print("Connected:", addr) # Step 1: Ask for authentication conn.send(b"AUTH:") # Step 2: Receive client key client_key = conn.recv(1024).decode().strip() if client_key != SECRET_KEY: conn.send(b"AUTH_FAILED") conn.close() else: conn.send(b"AUTH_OK") print("Client authenticated successfully!") # Continue your normal string-based message exchange while True: data = conn.recv(1024).decode() if not data: break print("Received:", data) conn.send(b"Response from server. Thank you I received data.") conn.close()
Broadcast receiver (Sample Code)
import socket HOST = "127.0.0.1" # Server IP (change as needed) PORT = 10124 # Port to read from (use your response socket port) try: # Create TCP socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) print(f"Connected to {HOST}:{PORT}") while True: data = s.recv(1024) # Receive up to 1024 bytes if not data: break # Connection closed print("Received:", data.decode().strip()) except Exception as e: print("Error:", e) finally: s.close()

Server-side (Bridge) Behavior

Error Handling & Response Codes

Use consistent error responses. Example values:

Example error reply:
1004|REJECTED|Requested order string is not as per requirement.\n

Performance & Best Practices

For example:

These give customers confidence that your system is reliable

RMS

Risk Management System is a control layer that ensures all trades follow predefined risk limits and regulatory rules before orders are sent to the exchange.

RMS ensures that only valid and permitted orders are placed in the market. It protects traders, brokers, and exchanges from financial, operational, and compliance risks.

Orders are validated against predefined RMS rules.

Note: The RMS checks listed above are standard validations. Users can add various other custom RMS checks as per their specific requirements. Our system is flexible and can accommodate additional risk management rules beyond those mentioned here.

Margin

Margin checks are applied post order acceptance.

We show Total Margin.
API has facility to restrict order on margin breach.

Real-Time Trade Monitor

The Bridge API provides comprehensive real-time monitoring capabilities to track all your trading activities. Our monitoring interface gives you complete visibility into your trades, positions, and order execution status.

Live Trade View

Monitor all executed trades in real-time with detailed information including instance number, execution time, symbol, quantity, and price. The live trade view helps you track your trading activity as it happens, providing instant feedback on order executions.

Live Trade Monitor

Live Trade Monitor - Real-time view of all executed trades

Detailed Net Position View

Get comprehensive position tracking with our detailed net position monitor. This view provides in-depth analysis including quantity exposure, rupee exposure, threshold quantities, buy/sell values, profit/loss calculations, and real-time margin requirements. The square-off thresholds help you manage risk effectively.

Detailed Net Position Monitor

Detailed Net Position Monitor - Comprehensive position tracking with P&L analysis

Key Features

Troubleshooting & FAQ

If the order execution socket disconnects due to any network issue, the Bridge API automatically cancels all open orders and shuts down to prevent unintended trades. This safety mechanism ensures no orphaned orders remain active during connectivity issues.

Yes, the Bridge API can be seamlessly integrated with exchange simulation or test environments to validate order flows and strategy behavior before live deployment. This allows you to thoroughly test your strategies in a risk-free environment.

Market data, provided directly by the broker, is delivered through a dedicated broadcast socket that runs continuously during market hours. This ensures real-time, reliable data streaming for your trading strategies.

Yes. Users can provide a configuration file specifying selected securities/instruments to subscribe to. This allows you to receive market data only for the instruments you're interested in, reducing bandwidth and processing requirements.

The exchange rejection or system level RMS rejection is sent back to the client via the response socket with appropriate error and reason codes. This allows your application to handle rejections gracefully and take appropriate action.

The Bridge API is engineered for low-latency order execution, typically delivering millisecond-level processing depending on the network topology and deployment environment. Actual latency may vary based on your infrastructure and network conditions.

Yes. Bridge API maintains detailed logs for orders, responses, trades, and system events for audit and troubleshooting. These logs are essential for compliance, debugging, and performance analysis.

The number of strategies is not limited, as the system operates over socket-based connectivity. Users can create multiple socket connections to run different strategies simultaneously, allowing for flexible and scalable trading operations.

On restart or failure, the Bridge API ensures safety by cancelling open orders and requiring fresh client connections. This prevents stale orders from being executed and ensures a clean state after any system interruption.