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 | df ‘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.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('NFO', "37516")
@ws.on_message(MessageTopic.DEPTH_FEED)
def msg_handler(client: WsClient, message: Any):
print(message)
ws.connect(uid='uid', actid='actid')
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"))
});
using thefirstock;
var exitEvent = new ManualResetEvent(false);
using (var client = firstock.initializeWebSocket())
{
client.MessageReceived.Subscribe(msg =>
{
Console.WriteLine("Message received: " + msg);
client.Send(firstock.subscribeDepth("NSE|26000"));
});
client.Start();
client.Send(firstock.startWebsockets());
exitEvent.WaitOne();
}
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': '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'
}