Order lifecycle & time-in-force
An order moves through a lifecycle from submission to a terminal state. Boursa exposes both a granular internal state and an Alpaca-aligned status.
States and statuses
Internal state | Alpaca status | Meaning |
|---|---|---|
received | pending_new | accepted by Boursa, pre-validation |
validated | accepted | reserved; accepted but not yet routed (e.g. placed while the market is closed → queued for next open) |
transmitted | pending_new | routed to the broker, awaiting acknowledgement |
acked | new | live and working at the venue (a resting limit sits here) |
partially_filled | partially_filled | some quantity filled, the rest still working |
filled | filled | terminal — fully executed |
cancel_requested | pending_cancel | a cancel is in flight |
cancelled | canceled | terminal — canceled |
expired | expired | terminal — a day order reached session close |
rejected | rejected | terminal — failed validation or broker rejection |
status=open ≈ {pending_new, accepted, new, partially_filled, pending_cancel}; status=closed ≈ {filled, canceled, expired, rejected}. List with GET /v1/orders?status=open|closed.
Resting limit orders
A limit order away from the market does not execute early — it rests in the broker's book and fills the moment the live price crosses it, at the market price:
- Buy limit fills when the market falls to (or below) your limit.
- Sell limit fills when the market rises to (or above) your limit.
While resting, the order shows status: new.
Time-in-force and expiry
day— expires at session close. After the close it isexpiredand the reservation is released.gtc— survives session close and rests across days. It is never self-expired; only you can cancel it.ioc/fok— never rest. An unmarketableioc/fokiscanceledimmediately (not rejected).
After-hours orders
An order placed while the market is closed is accepted, validated, and reserved — it shows status: accepted and transmits automatically at the next session open. (Funding and fund subscriptions behave differently — fund orders execute immediately at the current NAV.)
Partial fills
A partially-filled order stays partially_filled (still cancelable for the remainder) until the rest fills or the day order expires. In the sandbox, an order with qty: 13 deterministically fills in two parts to demonstrate this.
Cancel races
A fill is always truth. If you request a cancel and a fill lands first, the order fills — the cancel is a no-op. This is intentional and matches how real venues resolve the race.