On this page
Getting an order number back is not the end of the story. It is the beginning of one.
stat: "Ok" plus a norenordno means the order was accepted. It does not mean it traded, and it does not mean it will.
An accepted order can still be rejected by the exchange, filled in pieces, or sit untouched all day. If your code stops at the order number, it does not know what happened to the order.
The states
status | Meaning | Can you still act on it? |
|---|---|---|
PENDING | Received by Infinn, not yet acknowledged by the exchange. | not yet |
OPEN | Live in the market, waiting to match. | yes |
TRIGGER_PENDING | A stop-loss order waiting for its trigger price. | yes |
COMPLETE | Fully filled. | no — terminal |
CANCELED | Withdrawn before filling. | no — terminal |
REJECTED | Refused by Infinn or the exchange. Read rejreason. | no — terminal |
INVALID_STATUS_TYPE | A sentinel in the annexure, not an order state you should see. | - |
Report types: the events, not the states
status tells you where an order is. rpt - called reporttype on the WebSocket feed - tells you what just happened. One order produces many report types as it moves.
[
{ "status": "COMPLETE", "rpt": "Fill", "fillshares": "180", "avgprc": "800.00" },
{ "status": "OPEN", "rpt": "New", "prc": "800.00", "qty": "180" },
{ "status": "PENDING", "rpt": "PendingNew" },
{ "status": "PENDING", "rpt": "NewAck" }
]In the published sample the first element is the final Fill and the last is the initial NewAck. Reverse the array to read the story forwards.
| rpt |
|---|
NewAck |
ModAck |
CanAck |
PendingNew |
PendingReplace |
PendingCancel |
New |
Replaced |
Canceled |
Fill |
Rejected |
ReplaceRejected |
CancelRejected |
INVALID_REPORT_TYPE |
The WebSocket feed emits a longer list, including lifecycle events such as Triggered, lapsed, Frozen and the after-market variants. See the WebSocket annexure.
Which states you can still act on
| Operation | Allowed statuses | Otherwise |
|---|---|---|
| Modify Order | OPEN, TRIGGER_PENDING | Rejected : ORA:Order not found |
| Cancel Order | OPEN, TRIGGER_PENDING | Rejected : ORA:Order not found to Cancel |
| Exit Cover / Bracket | An open cover or bracket order | Cover and bracket orders only - products H and B |
An order can fill in the gap between you reading it as OPEN and your modification arriving. The result is Rejected : ORA:Order not found.
That is not a bug in your code and not an error worth alarming the user about - it means the order did what you wanted before you changed your mind. Handle it as a normal outcome.
Partial fills
A large order often fills in pieces. Between the first piece and the last, the order is partly done.
| Field | Meaning | Example |
|---|---|---|
qty | What you asked for | 180 |
fillshares | What has filled so far | 120 |
avgprc | Average price across the filled quantity | 800.00 |
cancelqty | Withdrawn, on a cancelled order | 60 |
status | Stays OPEN until the whole quantity fills | OPEN |
Cancellation withdraws only the unfilled balance. The part that already traded is a trade, and trades cannot be undone - you would have to place an opposing order to reverse the position.
Two ways to follow an order
| Order Book (REST) | Order updates (stream) | |
|---|---|---|
| Gives you | Every order's current state | Each change as it happens |
| Latency | Your polling interval | Immediate |
| Rate limit cost | One request per poll | None after connecting |
| Shows the path | No - only the latest state | Yes - every event |
| Survives a restart | Yes - it is a fresh read | No - nothing is replayed |
| Use it for | Establishing state at startup and after a reconnect | Staying current thereafter |
Call Order Book once at startup to establish where everything stands, then keep that picture current from the order update feed. That combination needs no polling at all and stays correct across reconnects.
Status values are not consistently cased
The annexure documents upper-case values: OPEN, REJECTED, COMPLETE. The published Order Book sample response contains "status": "Open" and "status": "REJECT" - different capitalisation, and REJECT rather than REJECTED.
# Both spellings of "rejected" appear in the documentation, in different
# cases. Normalise before comparing, and accept both.
TERMINAL = {"complete", "canceled", "cancelled", "rejected", "reject"}
ACTIONABLE = {"open", "trigger_pending"}
def is_terminal(order):
"""True when nothing further will happen to this order."""
return str(order.get("status", "")).strip().lower() in TERMINAL
def can_modify(order):
"""True when the order can still be modified or cancelled."""
return str(order.get("status", "")).strip().lower() in ACTIONABLEThe GTT lifecycle is different
A GTT order does not enter the states above when you create it. It waits, outside the order book entirely, until its price condition is met - and only then becomes an ordinary order that begins at PENDING.
| Stage | Where it lives | How to see it |
|---|---|---|
| You create it | The GTT list. Not the order book. | Get Pending GTT Orders |
| Waiting | Still the GTT list. No margin is blocked. | The same endpoint |
| The trigger price is reached | An ordinary order is created and enters PENDING. | Order Book, and an alert update on the stream |
| From then on | Exactly like any other order. | The order book and order updates |
Use Get Pending GTT Orders for the ones still waiting. They appear in the ordinary order book only after they fire.
A tracker that handles all of it
"""Track every order for a session, without polling.
One Order Book call establishes the starting picture; the WebSocket order
feed keeps it current. Reconnects re-seed from the book, because the stream
has no replay and anything that happened while disconnected is simply gone.
"""
import json
import threading
TERMINAL = {"complete", "canceled", "cancelled", "rejected", "reject"}
class OrderTracker:
def __init__(self):
self.orders = {}
self._lock = threading.Lock()
# --- seeding ------------------------------------------------------------
def seed(self, order_book_rows):
"""Replaces local state from an Order Book response."""
if not isinstance(order_book_rows, list):
return
with self._lock:
self.orders = {
row["norenordno"]: dict(row)
for row in order_book_rows if row.get("norenordno")
}
# --- streaming ----------------------------------------------------------
def apply(self, message):
"""Applies one 'om' order-update message.
The stream uses different names from the REST endpoints -- pcode
rather than prd, reporttype rather than rpt -- so those are mapped
here, at the boundary, rather than everywhere downstream.
"""
if message.get("t") != "om":
return None
ordno = message.get("norenordno")
if not ordno:
return None
patch = dict(message)
if "pcode" in patch:
patch["prd"] = patch.pop("pcode")
if "reporttype" in patch:
patch["rpt"] = patch.pop("reporttype")
with self._lock:
# Merge, do not replace: an update carries only what changed.
current = self.orders.setdefault(ordno, {})
current.update(patch)
return dict(current)
# --- queries ------------------------------------------------------------
def open_orders(self):
with self._lock:
return [
dict(o) for o in self.orders.values()
if str(o.get("status", "")).lower() not in TERMINAL
]
def filled_quantity(self, ordno):
with self._lock:
return int(self.orders.get(ordno, {}).get("fillshares") or 0)