Skip to content

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
‘o’ represents order update subscription task
actid Account id based on which order updated to be sent.

Code

from typing import Any
from thefirstock import thefirstock
from thefirstock.pyClient.websocket import WsClient
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_order('PP1583')


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


      ws.connect(uid='PP1583', actid='PP1583')
   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.subscribeOrderUpdate("#actid")) //Replace with actid
}); 

Subscription Acknowledgement

Parameter Description
t ok
‘ok’ represents order update subscription acknowledgement

Order Update subscription Updates

Parameter Description
t om
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