Skip to content

Subscribe Depth

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

Request Details: Parameter

Parameter Description
t d
‘d’ represents depth subscription
k One or more scriplist for subscription. Example NSE

Request Details

Parameter Description
t d
‘d’ represents depth subscription
k One or more scriplist for subscription. Example NSE

Code

from typing import Any
from thefirstock import thefirstock
from thefirstock.pyClient.websocket import WsClient
from thefirstock.pyClient.websocket.enums import MessageTopic

client = thefirstock.webSocketLogin()
ws = client.ws

@ws.on_connect
def connected(client, message):
if message.get('s') == 'OK':
client.subscribe_depth('PP1583')


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


ws.connect(uid='SR1598', actid='SR1598')
ws.run_forever()
const Firstock = require('thefirstock');
const firstock = new Firstock();


const ws = firstock.initializeWebSocket();

ws.on('open', function open() {
    firstock.getWebSocketDetails((err, result) => {
        if (!err) {
            ws.send(result)
        }
    })
});

ws.on("error", function error(error) {
    console.log(`WebSocket error: ${error}`)
})

ws.on('message', function message(data) {
    const result = firstock.receiveWebSocketDetails(data)
    console.log('Result: ', result)
    ws.send(firstock.subscribeDepth("NSE|26000#NSE|26009#NSE|26017"))
}); 

Subscription Depth Acknowledgement

Parameter Description
t dk
‘dk’ represents depth acknowledgement
e NSE, BSE, NFO ..
Exchange name
tk 22
Scrip Token
lp LTP
pc Percentage change
v volume
o Open price
h High price
l Low price
c Close price
ap Average trade price
ltt Last trade time
ltq Last trade quantity
tbq Total Buy Quantity
tsq Total Sell Quantity
bq1 Best Buy Quantity 1
bq2 Best Buy Quantity 2
bq3 Best Buy Quantity 3
bq4 Best Buy Quantity 4
bq5 Best Buy Quantity 5
bo1 Best Buy Orders 1
bo2 Best Buy Orders 2
bo3 Best Buy Orders 3
bo4 Best Buy Orders 4
bo5 Best Buy Orders 5
sq1 Best Sell Quantity 1
sq2 Best Sell Quantity 2
sq3 Best Sell Quantity 3
sq4 Best Sell Quantity 4
sq5 Best Sell Quantity 5
sp1 Best Sell Price 1
sp2 Best Sell Price 2
sp3 Best Sell Price 3
sp4 Best Sell Price 4
sp5 Best Sell Price 5
so1 Best Sell Orders 1
so2 Best Sell Orders 2
so3 Best Sell Orders 3
so4 Best Sell Orders 4
so5 Best Sell Orders 5
lc Lower Circuit Limit
uc Upper Circuit Limit
52h 52 week high low in other exchanges, Life time high low in mcx
52l 52 week high low in other exchanges, Life time high low in mcx

Depth subscription Updates

Parameter Description
t dk
‘dk’ represents depth acknowledgement
e NSE, BSE, NFO ..
Exchange name
tk 22
Scrip Token
lp LTP
pc Percentage change
v volume
o Open price
h High price
l Low price
c Close price
ap Average trade price
ltt Last trade time
ltq Last trade quantity
tbq Total Buy Quantity
tsq Total Sell Quantity
bq1 Best Buy Quantity 1
bq2 Best Buy Quantity 2
bq3 Best Buy Quantity 3
bq4 Best Buy Quantity 4
bq5 Best Buy Quantity 5
bo1 Best Buy Orders 1
bo2 Best Buy Orders 2
bo3 Best Buy Orders 3
bo4 Best Buy Orders 4
bo5 Best Buy Orders 5
sq1 Best Sell Quantity 1
sq2 Best Sell Quantity 2
sq3 Best Sell Quantity 3
sq4 Best Sell Quantity 4
sq5 Best Sell Quantity 5
sp1 Best Sell Price 1
sp2 Best Sell Price 2
sp3 Best Sell Price 3
sp4 Best Sell Price 4
sp5 Best Sell Price 5
so1 Best Sell Orders 1
so2 Best Sell Orders 2
so3 Best Sell Orders 3
so4 Best Sell Orders 4
so5 Best Sell Orders 5
lc Lower Circuit Limit
uc Upper Circuit Limit
52h 52 week high low in other exchanges, Life time high low in mcx
52l 52 week high low in other exchanges, Life time high low in mcx

Sample Response

[
{
"t": "df",
"e": "NSE",
"tk": "22",
"o": "1166.00",
"h": "1179.00",
"l": "1145.35",
"c": "1152.65",
"ap": "1159.74",
"v": "819881",
"tbq": "120952",
"tsq": "131730",
"bp1": "1156.00",
"sp1": "1156.50",
"bp2": "1155.80",
"sp2": "1156.55",
"bp3": "1155.75",
"sp3": "1156.65",
"bp4": "1155.70",
"sp4": "1156.70",
"bp5": "1155.65",
"sp5": "1156.75",
"bq1": "4",
"sq1": "10",
"bq2": "67",
"sq2": "63",
"bq3": "83",
"sq3": "1",
"bq4": "139",
"sq4": "53",
"bq5": "393",
"sq5": "94"
}
]