Skip to content

Websocket Market Data


The Websocket endpoint helps the user to retrieve the data for the instruments in almost realtime. It is the most efficient way to retrieve the data as it requires less amount of resources which in turn reduces the latency to a very large extent.

Connection

The endpoint for websocket connection is wss://wss.tiqs.trading. To establish a new connection, the user needs to pass on the following query params

wsURL = "wss://wss.tiqs.trading?appId=<YOUR_APP_ID>&token=<YOUR_TOKEN>"

Sending Message

The websocket receives a JSON string in the following format for the quotes

Payload Structute
{
  "code": "SUBSCRIPTION MODE",
  "mode": "QUOTE MODE",
  "QUOTE MODE": "Array of Tokens"
}
Sample Payload for subscribing ltpc mode
{
  "code": "sub",
  "mode": "ltpc",
  "ltpc": [26009, 26000]
}
Sample Payload for subscribing ltp mode
{
  "code": "sub",
  "mode": "ltp",
  "ltp": [26009, 26000]
}
Sample Payload for subscribing quote mode
{
  "code": "sub",
  "mode": "quote",
  "quote": [26009, 26000]
}
Sample Payload for subscribing full mode
{
  "code": "sub",
  "mode": "full",
  "full": [26009, 26000]
}

Subscription Modes

These are the following subscription modes

Subscription Mode Description
sub For Subscribing the Tokens
unsub For Unsubscribing the Tokens

Quotes Modes

These are the following quotes modes which can be subscribed

Quote Mode Description Packet Size
ltpc The packet contains info about LTP data with closing Price 17 bytes
ltp The packet contains info about LTP data without closing Price 13 bytes
quote The packet contains info except market depth 93 bytes
full The packet contains info including market depth 241 bytes

Market Data Structure for LTPC

Position Field Type
0 - 4 Token int32
4 - 8 LTP int32
8 - 9 Net change indicator int32
9 - 13 Net change int32
13 - 17 Previous Trading Day Close Price int32

Note

The extra LTPC Mode is there to have the Previous Day Closing Price as the net change is based on the previous day Settlement Price instead of the Closing Price

Market Data Structure for LTP, Quote and Full

Position Field Type
0 - 4 Token int32
4 - 8 LTP int32
8 - 9 Net change indicator int8
9 - 13 Net change int32
13 - 17 LTQ int32
17 - 21 Avg Price int32
21 - 29 Total Buy Quantity int64
29 - 37 Total Sell Quantity int64
37 - 41 Open int32
41 - 45 High int32
45 - 49 Close int32
49 - 53 Low int32
53 - 61 Volume int64
61 - 65 LTT int32
65 - 69 Time int32
69 - 77 OI int64
77 - 85 OI day high int64
85 - 93 OI day low int64
93 - 97 Lower limit int32
97 - 101 Upper limit int32
101 - 241 Market Depth byte[]

Market Depth Structure

The Market Depth Structure consists of 5 Bids and 5 Offers. Each of the Bid and Offer is 14 byte packet. Each Packet of 14 bytes is a combination of quantity(int64, 8 bytes), price (int32, 4 bytes) and orders (int16, 2 bytes)

Position Field Type
101 - 115 Bid-1 int64, int32, int16
115 - 129 Bid-2 int64, int32, int16
129 - 143 Bid-3 int64, int32, int16
143 - 157 Bid-4 int64, int32, int16
157 - 171 Bid-5 int64, int32, int16
171 - 185 Offer-1 int64, int32, int16
185 - 199 Offer-2 int64, int32, int16
199 - 213 Offer-3 int64, int32, int16
213 - 227 Offer-4 int64, int32, int16
227 - 241 Offer-5 int64, int32, int16