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 81 bytes
full The packet contains info including market depth 229 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 int32
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 - 73 OI int32
73 - 77 OI day high int32
77 - 81 OI day low int32
81 - 85 Lower limit int32
85 - 89 Upper limit int32
89 - 229 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
89 - 103 Bid-1 int64, int32, int16
103 - 117 Bid-2 int64, int32, int16
117 - 131 Bid-3 int64, int32, int16
131 - 145 Bid-4 int64, int32, int16
145 - 159 Bid-5 int64, int32, int16
159 - 173 Offer-1 int64, int32, int16
173 - 187 Offer-2 int64, int32, int16
187 - 201 Offer-3 int64, int32, int16
201 - 215 Offer-4 int64, int32, int16
215 - 229 Offer-5 int64, int32, int16