On this page
In plain English

Instead of asking 'has my order filled yet?' over and over, you are told the moment anything happens to it -- accepted, partially filled, filled, rejected or cancelled. This is the correct way to track orders.

WSwss://api.infinn.in/NorenWSTP/

What it does

Pushes every change to your orders as it happens.

There is no subscribe message -- only an unsubscribe

Order updates start flowing as soon as the connection is authenticated. The documentation provides uo to turn them off but no matching message to turn them back on, so treat unsubscribing as a one-way decision for the lifetime of that connection.

The field names differ from the REST endpoints

The same concepts carry different names here: product is pcode on the stream but prd over REST, and the event type is reporttype here but rpt in the order book. If you merge stream and REST data into one model, normalise the names at the boundary.

This is how you avoid polling

Combining this feed with a single Order Book call at startup gives you a complete, live picture for the whole session without ever polling. The order tracking guide shows the pattern.

A longer list of report types applies to the stream

The WebSocket annexure documents many more reporttype values than the REST annexure does, including lifecycle events such as Triggered, lapsed, Frozen and the AMO variants. See the annexure.

Messages you send

Unsubscribe from order updates t: "uo"

Client → server

Stops order updates for this connection.

Example message
{ "t": "uo" }
Unsubscribe from order updates fields
FieldTypeDescription
tstring

Always the literal 'uo'.

Messages you receive

Order update t: "om"

Server → client

Pushed on every order event. No subscribe message is needed: order updates begin arriving once the connection is authenticated.

Order update fields
FieldTypeDescription
tstring

Always 'om'.

norenordnostring

Infinn order number.

uidstring

User ID.

actidstring

Account ID. For an individual account it equals uid (confirmed live).

exchstring

Exchange.

tsymstring

Trading symbol.

qtystring

Order quantity.

prcstring

Order price.

pcodestring

Product. Note the name: this field is pcode on the stream, while the REST endpoints call the same thing prd.

statusstring

Order status, for example New, Replaced, Complete or Rejected.

reporttypestring

The event this message reports, for example Fill, Rejected or Canceled. On the REST endpoints the equivalent field is called rpt.

trantypestring

Buy or sell.

prctypstring

Price type: LMT, MKT, SL-LMT or SL-MKT.

retstring

Retention type: DAY, EOS or IOC.

fillsharesstring

Total quantity filled on this order.

avgprcstring

Average fill price.

fltmstring

Fill time.

PresenceOnly when reporttype is Fill.
flidstring

Fill ID.

PresenceOnly when reporttype is Fill.
flqtystring

Fill quantity.

PresenceOnly when reporttype is Fill.
flprcstring

Fill price.

PresenceOnly when reporttype is Fill.
rejreasonstring

Rejection reason.

PresenceOnly when rejected.
exchordidstring

Exchange order ID.

cancelqtystring

Cancelled quantity.

PresenceOnly when cancelled.
remarksstring

The tag you added when placing the order.

dscqtystring

Disclosed quantity.

trgprcstring

Trigger price, for SL orders.

snonumstring

Child-order sequence number for cover and bracket orders. If present, send it when exiting.

PresenceCover and bracket child orders.
snoordtstring

Whether the child order is the profit or the stop-loss leg.

PresenceCover and bracket child orders.
blprcstring

Differential stop-loss trigger price.

PresenceCover and bracket parent orders.
bpprcstring

Differential profit price.

PresenceBracket parent orders.
trailprcstring

Trailing price, if trailing ticks are enabled.

PresenceCover and bracket parent orders.
exch_tmstring

Exchange update time, formatted dd-mm-YYYY hh:MM:SS.

amostring

Present with the value "Yes" when the order is an after-market order.

tmstring

Timestamp.

ntmstring

Nanosecond timestamp.

kididstring

Kid ID.

sno_fillidstring

Bracket-order sequence ID.

rejbystring

Which system rejected the order.

PresenceOnly when rejected.
dnamestring

Broker-specific contract display name.

handlinststring

Handling instruction: DMA, TOUCH or WO.

ordenttmstring

Order entry time.

uidcstring

UI device code.

osstring

Order source.

aistring

Algo ID.

Unsubscribe acknowledgement t: "uok"

Server → client

Unsubscribe acknowledgement fields
FieldTypeDescription
tstring

Always 'uok'.

Working example

A complete Python client for this feed. It needs only the websocket-client package (pip install websocket-client).

Python
"""Infinn WebSocket client -- Order updates.

Requires: pip install websocket-client
"""
import json
import threading
import time

import websocket  # websocket-client

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
UID = "IN001"

# Merged state per token. The acknowledgement carries a full snapshot and
# every later update carries only what changed, so updates must be MERGED
# into this, never used to replace an entry.
state = {}


def on_open(ws):
  # Step 1: authenticate. Nothing else is honoured until "ak" arrives.
  ws.send(json.dumps({
      "t": "a",
      "uid": UID,
      "actid": UID,
      "source": "API",
      "accesstoken": ACCESS_TOKEN,
  }))


def on_message(ws, raw):
  msg = json.loads(raw)
  kind = msg.get("t")

  if kind == "ak":
      # The documentation says "Ok or Not_Ok"; the live feed sends "NOT_OK".
      # Compare case-insensitively.
      if str(msg.get("s", "")).lower() != "ok":
          print("Authentication refused:", msg)
          ws.close()
          return
      print("Authenticated. Subscribing.")
      threading.Thread(target=heartbeat, args=(ws,), daemon=True).start()
      return

  # Acknowledgements carry a full snapshot; feeds carry deltas.
  if kind in ("tk", "dk", "lk"):
      state[msg["tk"]] = dict(msg)
  elif kind in ("tf", "df", "lf"):
      state.setdefault(msg["tk"], {}).update(msg)
  elif kind == "hk":
      return  # heartbeat acknowledged
  else:
      print(kind, msg)
      return

  row = state[msg["tk"]]
  print(f'{row.get("ts", row["tk"]):<16} {row.get("lp", "-"):>10}')


def heartbeat(ws):
  # No interval is published. 30s is comfortably inside any plausible
  # idle timeout for a feed of this kind.
  while ws.keep_running:
      time.sleep(30)
      try:
          ws.send(json.dumps({"t": "h"}))
      except Exception:
          return


def on_error(ws, err):
  print("error:", err)


def on_close(ws, code, reason):
  # 1008 (PolicyViolation) is what the server sends when it rejects
  # your credentials.
  print(f"closed: {code} {reason}")


if __name__ == "__main__":
  websocket.WebSocketApp(
      "wss://api.infinn.in/NorenWSTP/",
      on_open=on_open,
      on_message=on_message,
      on_error=on_error,
      on_close=on_close,
  ).run_forever()
Esc
↑↓ navigate↵ openEsc close/ to search