Subscribe order update
Websocket Order Status API will function in providing order status updates through websocket server connection and provide Order responses similar to the one received in Postback/Webhook.
Request details
Parameter | Description |
---|---|
t | 'o' represents order update subscription task |
actid | Account id based on which order updated to be sent. |
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_order('userId')
@ws.on_message(MessageTopic.ORDER_FEED)
def msg_handler(client: WsClient, message: Any):
print(message)
ws.connect(uid='<userId>', actid='<userId>')
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) {
firstock.initialSendWebSocketDetails(ws, result, () => {
ws.send(firstock.subscribeOrderUpdate("actid"));
});
}
});
});
ws.on("error", function error(error) {
console.log(`WebSocket error: ${error}`);
});
ws.on("message", function message(data) {
const result = firstock.receiveWebSocketDetails(data);
console.log("message: ", result);
});
using thefirstock;
var exitEvent = new ManualResetEvent(false);
using (var client = firstock.initializeWebSocket()){
client.MessageReceived.Subscribe(msg =>
{
Console.WriteLine("Message received: " + msg);
client.Send(firstock.subscribeOrderUpdate("NSE|TV0001"));
});
client.Start();
client.Send(firstock.startWebsockets());
exitEvent.WaitOne();
}
Subscription Acknowledgement
Parameter | Description |
---|---|
t | 'ok' represents order update subscription acknowledgement |
Order Update subscription Updates
Parameter | Description |
---|---|
t | 'om' represents touchline feed |
norenordno | Noren Order Number |
uid | User Id |
actid | Account ID |
exch | Exchange Segment |
tsym | Trading symbol |
qty | Order Quantity |
prc | Order Price |
prd | C / M / I Product name |
status | Order status (New, Replaced, Complete, Rejected etc) |
reporttype | Order event for which this message is sent out. (Fill, Rejected, Canceled) |
trantype | Order transaction type, B -> Buy , S -> Sell |
prctyp | Order price type (LMT, MKT, SL-LMT, SL-MKT) |
ret | Order retention type (DAY, EOS, IOC) |
fillshares | Total Filled shares for this order |
avgprc | Average fill price |
fltm | Fill Time(present only when reporttype is Fill) |
flid | Fill ID(present only when reporttype is Fill) |
flqty | Fill Qty(present only when reporttype is Fill) |
flprc | Fill Price(present only when reporttype is Fill) |
rej | Order rejection reason, if rejected |
exchordid | Exchange Order ID |
cancelqty | Canceled quantity, in case of canceled order |
remarks | User added tag, while placing order |
dscqty | Disclosed quantity |
trgprc | Trigger price for SL orders |
exch_tm | This will have the exchange update time |
Sample Response
- Success response
{'t': 'om', 'norenordno': '', 'uid': '', 'actid': '', 'exch': 'NSE', 'tsym': 'TCS-EQ', 'trantype': 'B', 'qty': '1', 'prc': '3101.10', 'pcode': 'I', 'remarks': '', 'status': 'PENDING', 'reporttype': 'NewAck', 'prctyp': 'LMT', 'ret': 'DAY', 'exchordid': '', 'dscqty': '0'}
{'t': 'om', 'norenordno': '', 'uid': '', 'actid': '', 'exch': 'NSE', 'tsym': 'TCS-EQ', 'trantype': 'B', 'qty': '1', 'prc': '3101.10', 'pcode': 'I', 'remarks': '', 'status': 'PENDING', 'reporttype': 'PendingNew', 'prctyp': 'LMT', 'ret': 'DAY', 'exchordid': '', 'dscqty': '0'}
{'t': 'om', 'norenordno': '', 'uid': '', 'actid': '', 'exch': 'NSE', 'tsym': 'TCS-EQ', 'trantype': 'B', 'qty': '1', 'prc': '3101.10', 'pcode': 'I', 'remarks': '', 'status': 'OPEN', 'reporttype': 'New', 'prctyp': 'LMT', 'ret': 'DAY', 'exchordid': '', 'dscqty': '0', 'exch_tm': ''}