View Markdown Β· Documentation index (llms.txt)
Learning Guide β Order Management and Matcher: purpose, walkthrough, and related learning states.
Contract Delta: 009-order-management-matcher
Parent state: 008-pricing-awareness-market-data
Document any API/event/schema changes for this state.
OpenAPI Changesβ
- Add order-management endpoints (exact path naming finalized in implementation):
POST /orders(create order; acceptsaccountId,security,side,quantity, optionalorderType[LIMIT,MARKET] defaulting toLIMIT, andlimitPricewhich is required forLIMITand nullable/optional forMARKET)GET /orders(query/filter orders)GET /orders/{orderId}(order details)POST /orders/{orderId}/cancel(cancel order; valid forNEWandPARTIALLY_FILLEDstatuses)POST /orders/{orderId}/force-fill(admin action; valid forNEWandPARTIALLY_FILLEDnon-MARKET orders)
- Add matcher/admin health endpoint:
GET /order-matcher/health
- Add matcher metrics endpoint:
GET /order-matcher/metrics(Prometheus text exposition)
Integration Contract Changesβ
- Order fills must submit trades via existing trade-service API:
POST /trade-service/trade/(through ingress) orPOST /trade/(service internal path)
- Position/trade persistence contract remains the existing trade pipeline:
- trade-service -> trade-processor -> position-service
Metrics Contract Additionsβ
Prometheus metric names required for order observability:
traderx_orders_open_total(gauge)traderx_orders_unfilled_total(gauge)traderx_orders_pending_by_side{side="Buy|Sell"}(gauge)traderx_order_events_total{event="create|partial_fill|fill|cancel|reject|force_fill"}(counter)traderx_order_match_latency_seconds_bucket/_sum/_count(histogram)traderx_order_book_age_seconds_bucket/_sum/_count(histogram)
Compatibility Notesβ
- Existing trade/position/pricing APIs remain backward-compatible from
008. - Order-management APIs are additive.
- UI market-trade flow remains available; order-ticket + account-orders tab is introduced as an additional path.
Retained database upgradeβ
Before exposing order operations, atomically backfill missing order types to LIMIT, set the LIMIT default and NOT NULL/allowed-value constraints, and drop LimitPrice NOT NULL. Preserve order IDs, quantities, statuses, prices, and timestamps. Apply safely on subsequent starts and fail startup on migration errors.
State-owned conformance for adapted implementationsβ
The durable-order/force-fill contract is inherited independently of implementation provenance (NFR-01322/01323). tests/conformance/run.py drives the order HTTP API and observes real trade submissions through an adapter-owned probe. See tests/conformance/README.md for the versioned protocol. Corporate adapters may change storage, migration tooling, language, and deployment topology while retaining this behavior. Do not duplicate the reference implementation merely to satisfy a structural check.