This is an old revision of the document!
Order Routing
The WebSocket API provides real-time order routing, allowing clients to submit, revise, and pull orders. All order-related operations are sent within a **ClientMessage** envelope and responses are received within a **ServerMessage** envelope.
Submitting an Order
To submit an order, clients send an OrderSubmit message.
Note: You must subscribe to the Account before submitting an order into it. Orders will be rejected if the account is not subscribed.
Example OrderSubmit message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.Limit, TimeType = TimeType.Normal, Volume = 5, LimitPrice = "4200.50" } ] }
Note: The OrderSubmit message allows submitting multiple orders at once.
Revising an Order
To revise an existing order, clients send an OrderRevise message.
Example OrderRevise message:
OrderRevise { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Revisions = [ { UniqueId = "a3b1c5f2-7d43-4f9b-88e2-1e2f75c6d9a1", Volume = 10, LimitPrice = "4250.00" } ] }
Note: The OrderRevise message allows revising multiple orders at once.
Pulling (Cancelling) an Order
To cancel an order, clients must send an OrderPull message with the order ID.
Example OrderPull message:
OrderPull { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Pulls = [ { UniqueId = "a3b1c5f2-7d43-4f9b-88e2-1e2f75c6d9a1" } ] }
Note: The OrderPull message allows pulling multiple orders at once.
Order Types
The WebSocket API supports a variety of order types to accommodate different trading strategies. Below are the supported order types, along with their corresponding OrderSubmit messages.
Market Order
A Market Order executes immediately at the best available price.
Example Market Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.Market, TimeType = TimeType.Normal, Volume = 1 } ] }
Limit Order
A Limit Order is submitted with a specific limit price. The order will only execute at the specified price or better.
Example Limit Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.Limit, TimeType = TimeType.Normal, Volume = 1, LimitPrice = "2376.50" } ] }
Stop Order
A Stop Market Order becomes a Market Order when the stop price is reached.
Example Stop Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.StopMarket, TimeType = TimeType.Normal, Volume = 1, StopPrice = "2376.50" } ] }
Stop Limit Order
A Stop Limit Order becomes a Limit Order when the stop price is reached.
Example Stop Limit Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.StopLimit, TimeType = TimeType.Normal, Volume = 1, StopPrice = "2375.00", LimitPrice = "2375.00" } ] }
Trailing Stop Order
A Trailing Stop Order moves the stop price automatically based on price movement.
Example Trailing Stop Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.StopMarket, TimeType = TimeType.Normal, Volume = 1, StopPrice = "2375.00", TrailPrice = "50" } ] }
Fill or Kill (FOK) Order
A Fill or Kill (FOK) Order must be executed immediately in full or it is canceled.
Example Fill or Kill (FOK) Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.Limit, TimeType = TimeType.CompleteVolume, Volume = 1, LimitPrice = "2375.00" } ] }
Immediate or Cancel (IOC) Order
An Immediate or Cancel (IOC) Order executes immediately for the available quantity and cancels the rest.
Example Immediate or Cancel (IOC) Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.Limit, TimeType = TimeType.ImmediateAndCancel, Volume = 1, LimitPrice = "2375.00" } ] }
Good Till Canceled (GTC) Order
A Good Till Canceled (GTC) Order remains open until it is filled or explicitly canceled.
Example Good Till Canceled (GTC) Order message:
OrderSubmit { UserId = "efda0709-af12-4b65-8971-5089edb4aaf0", AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620", MarketId = "XCME_C ZC (H25)", Orders = [ { BuySell = BuySell.Buy, PriceType = PriceType.Limit, TimeType = TimeType.GoodTillCancelled, Volume = 1, LimitPrice = "2375.00" } ] }