8. Order Status
Track order execution progress via polling
Objective
Track the execution progress of a specific order by polling the order book at short intervals.
Flow
Order Monitor Service → Trading API (Order Detail) → ExecutionOrder Statuses
| Status | Meaning |
|---|---|
PENDING (PD) | Accepted, not yet processed |
PENDING_APPROVAL | Awaiting approval |
READY / SENT / QUEUED | Waiting to match |
PARTIAL_FILLED | Partially filled |
PARTIAL_CANCELLED (FFPC) | Partially filled, remainder cancelled |
FILLED | Fully filled |
PENDING_MODIFY / PENDING_CANCEL | Waiting for a modification / cancellation to be confirmed |
CANCELLED | Cancelled |
REJECTED | Rejected |
EXPIRED | Expired |
The SDK declares more codes the server may send (PRE_SESSION, REQUESTED, ERROR...). Since SDK 3.3.0, Order.status can be an OrderStatus enum, a str (a new code the SDK does not know yet) or None: use helpers.enum_value (see page 1) to print it safely. PARTIAL_CANCELLED is also treated as a terminal status in the samples.
Sample Code — Sync
import time
from ssi_sdk import Auth, Trading, Config
from ssi_sdk.enums import OrderSide, OrderStatus
from auth_helper import ensure_auth
from helpers import enum_value
config = Config(
client_id="<your_client_id>",
api_key="<your_api_key>",
api_secret="<your_api_secret>",
private_key="<your_private_key>",
)
ACCOUNT_NO = "<your_account_no>"
TERMINAL_STATUSES = {
OrderStatus.FILLED, OrderStatus.CANCELLED,
OrderStatus.REJECTED, OrderStatus.EXPIRED,
OrderStatus.PARTIAL_CANCELLED,
}
with Auth(config) as auth:
ensure_auth(auth, otp="<your_otp>")
with Trading(auth) as trading:
result = trading.trading.place_limit_order(
account_no=ACCOUNT_NO, symbol="SSI",
side=OrderSide.BUY, quantity=100, price=26000,
)
for i in range(1, 11):
orders = trading.portfolio.get_today_orders(ACCOUNT_NO)
if orders and orders[-1].status in TERMINAL_STATUSES:
print(f" Order finished: {enum_value(orders[-1].status)}")
break
time.sleep(3)Sample Code — Async
import asyncio
from ssi_sdk import AsyncAuth, AsyncTrading, Config
from ssi_sdk.enums import OrderSide, OrderStatus
from auth_helper import ensure_auth_async
config = Config(...)
ACCOUNT_NO = "<your_account_no>"
TERMINAL_STATUSES = {
OrderStatus.FILLED, OrderStatus.CANCELLED,
OrderStatus.REJECTED, OrderStatus.EXPIRED,
OrderStatus.PARTIAL_CANCELLED,
}
async def main():
async with AsyncAuth(config) as auth:
await ensure_auth_async(auth, otp="<your_otp>")
async with AsyncTrading(auth) as trading:
result = await trading.trading.place_limit_order(
account_no=ACCOUNT_NO, symbol="SSI",
side=OrderSide.BUY, quantity=100, price=26000,
)
for i in range(1, 11):
orders = await trading.portfolio.get_today_orders(ACCOUNT_NO)
if orders and orders[-1].status in TERMINAL_STATUSES:
break
await asyncio.sleep(3)
asyncio.run(main())Notes
- Polling is suitable for quick checks. For real-time, use WebSocket Trading.
- Limit poll count and add timeout to avoid infinite loops.