Skip to main content

Subscribe depth

Websocket Subscribe Depth API will provide multiple instruments market information at once. (5 Depth,high, low, close, etc..)

Request details: Parameter

ParameterDescription
tdf ‘d’ represents depth subscription
kOne or more scriplist for subscription. Example NSE

Request Details

ParameterDescription
td ‘d’ represents depth subscription
kOne or more scriplist for subscription. Example NSE
from typing import Any
from thefirstock.firstockModules import firstockWebSockets
from thefirstock.pyClient.websocket import WsClient
from thefirstock.pyClient.websocket.enums import MessageTopic

client = firstockWebSockets.webSocketLogin()
ws = client.ws

@ws.on_connect
def connected(client, message):
if message.get('s') == 'OK':
client.subscribe_depth('NSE|26000#NSE|26009#NSE|22')

@ws.on_message(MessageTopic.DEPTH_FEED)
def msg_handler(client: WsClient, message: Any):
print(message)

ws.connect(uid='AA123', actid='AA123') #Replace uid & actid
ws.run_forever()

Subscription depth acknowledgement

ParameterDescription
t‘dk’ represents depth acknowledgement
eNSE, BSE, NFO ..Exchange name
tk22 Scrip Token
lpLTP
pcPercentage change
vvolume
oOpen price
hHigh price
lLow price
cClose price
apAverage trade price
lttLast trade time
ltqLast trade quantity
tbqTotal Buy Quantity
tsqTotal Sell Quantity
bq1Best Buy Quantity 1
bq2Best Buy Quantity 2
bq3Best Buy Quantity 3
bq4Best Buy Quantity 4
bq5Best Buy Quantity 5
bo1Best Buy Orders 1
bo2Best Buy Orders 2
bo3Best Buy Orders 3
bo4Best Buy Orders 4
bo5Best Buy Orders 5
sq1Best Sell Quantity 1
sq2Best Sell Quantity 2
sq3Best Sell Quantity 3
sq4Best Sell Quantity 4
sq5Best Sell Quantity 5
sp1Best Sell Price 1
sp2Best Sell Price 2
sp3Best Sell Price 3
sp4Best Sell Price 4
sp5Best Sell Price 5
so1Best Sell Orders 1
so2Best Sell Orders 2
so3Best Sell Orders 3
so4Best Sell Orders 4
so5Best Sell Orders 5
lcLower Circuit Limit
ucUpper Circuit Limit
52h52 week high low in other exchanges, Life time high low in mcx
52l52 week high low in other exchanges, Life time high low in mcx

Depth subscription Updates

ParameterDescription
tdk ‘dk’ represents depth acknowledgement
eNSE, BSE, NFO ..Exchange name
tk22 Scrip Token
lpLTP
pcPercentage change
vvolume
oOpen price
hHigh price
lLow price
cClose price
apAverage trade price
lttLast trade time
ltqLast trade quantity
tbqTotal Buy Quantity
tsqTotal Sell Quantity
bq1Best Buy Quantity 1
bq2Best Buy Quantity 2
bq3Best Buy Quantity 3
bq4Best Buy Quantity 4
bq5Best Buy Quantity 5
bo1Best Buy Orders 1
bo2Best Buy Orders 2
bo3Best Buy Orders 3
bo4Best Buy Orders 4
bo5Best Buy Orders 5
sq1Best Sell Quantity 1
sq2Best Sell Quantity 2
sq3Best Sell Quantity 3
sq4Best Sell Quantity 4
sq5Best Sell Quantity 5
sp1Best Sell Price 1
sp2Best Sell Price 2
sp3Best Sell Price 3
sp4Best Sell Price 4
sp5Best Sell Price 5
so1Best Sell Orders 1
so2Best Sell Orders 2
so3Best Sell Orders 3
so4Best Sell Orders 4
so5Best Sell Orders 5
lcLower Circuit Limit
ucUpper Circuit Limit
52h52 week high low in other exchanges, Life time high low in mcx
52l52 week high low in other exchanges, Life time high low in mcx

Sample response

{
't': 'df',
'e': 'NFO',
'tk': '37516',
'ft': '1662443826',
'tbq': '149300',
'tsq': '134500',
'bp1': '39888.05',
'bp2': '39888.00',
'bp3': '39887.15',
'sp3': '39894.55',
'bp4': '39887.10',
'sp4': '39894.60',
'bp5': '39886.80',
'sp5': '39894.95',
'bq1': '75',
'sq2': '100',
'bq3': '100',
'bq4': '100',
'sq4': '25',
'sq5': '100',
'bo1': '2',
'so2': '2',
'so3': '1',
'so5': '2'
}