Managed orders
All managed trading uses omsbridge.v1.Orders: CalculateOrder, SubmitOrder,
GetOrder, ListOrders, EditOrder, CancelOrder and WatchOrder.
Broker-specific order RPCs have been removed; old paths return UNIMPLEMENTED.
Existing broker orders are not imported. Pending, stop and profit orders and manual
resolution are outside the managed service.
Submit and watch
Section titled “Submit and watch”from omsbridge.v1.proto import bridge_pb2 as pbfrom omsbridge.v1.proto import bridge_pb2_grpc as stubs
async def submit_and_watch(connection, account_id): orders = stubs.OrdersStub(connection) intent = pb.SubmitOrderRequest( account_id=account_id, order_id="strategy-42-buy-1", terms=pb.OrderTerms( price=500, quantity=7, side=pb.ORDER_BUY, future=pb.FutureOrderParameters(contract_id=23), ), ) document = await orders.SubmitOrder(intent, timeout=10) async for document in orders.WatchOrder( pb.OrderRef(order_id=intent.order_id), timeout=300, ): print(document.state, document.filled_quantity, document.finalized)For Ephoenix, replace future with EphoenixOrderParameters in terms.ephoenix,
supplying account type, ISIN and validity (1 for today). Its price must be a
positive integer. Future defaults are limit (price_qualifier=0) and session
(validity=0); market is 1, IOC is 1 and FOK is 2 in their respective fields.
Prices remain in native broker units.
IDs and duplicate protection
Section titled “IDs and duplicate protection”- Choose your own
order_id. It is unique within the authenticated service client across all accounts and survives token rotation. - Use the same ID and identical terms after an uncertain RPC result. Repeating an
identical intent returns the current persisted document. Changed parameters
with the same ID return
ALREADY_EXISTS. - Supply a separate
operation_idfor every intended edit or cancellation. These IDs are also unique per service client and support identical retries. - Other clients cannot see your managed orders, even if they can administer the same account. Broker order/serial/request/book identities stay private.
EditOrder requires complete replacement terms and preserves instrument and side.
An unresolved operation blocks further edit/cancel operations. Ambiguous operations
on multi-record orders return FAILED_PRECONDITION.
Read the lifecycle correctly
Section titled “Read the lifecycle correctly”Submission persists intent; dispatch and tracking continue in the background.
PENDING_SUBMIT and OPEN do not mean filled.
| State | Meaning |
|---|---|
PENDING_SUBMIT |
Intent persisted; dispatch/outcome processing is pending |
UNKNOWN |
The dispatch outcome is unresolved |
OPEN |
Broker order is open |
PARTIALLY_FILLED |
Some executions are confirmed |
FILLED, CANCELLED, REJECTED, EXPIRED |
Terminal lifecycle state |
A terminal state may still await execution details. Check finalized before
treating reconciliation as complete. Confirmed executions determine filled quantity
and weighted average execution price. Cancellation preserves partial fills.
Uncertain edits/cancellations appear separately in last_operation.
WatchOrder immediately emits the latest committed document, follows increasing
revisions, emits a finalized document and closes. Watchers do not own tracking:
disconnecting or reaching a deadline does not stop reconciliation. Slow watchers
receive RESOURCE_EXHAUSTED; reconnect to receive the latest document.
ListOrders supports account/state filters, inclusive Asia/Tehran trading dates,
and keyset pagination (default 100, maximum 500).
Recovery and unresolved dispatches
Section titled “Recovery and unresolved dispatches”Bridge saves intent and a dispatch claim before contacting the broker, sends once,
journals the acknowledgement and then projects it. Startup recovers unfinished work.
An interrupted dispatch without a saved outcome becomes UNKNOWN.
One tracker per active account batches HTTP reports and reconciles on startup,
polling and hub reconnect. Hub statuses do not override HTTP snapshots.
order_poll_interval defaults to one second, transient failures back off to 30
seconds, and order_request_timeout defaults to 120 seconds. Run one Bridge per
database.