Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| developers:websocket:orders [2025/03/14 22:08] – chad | developers:websocket:orders [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <note warning> | ||
| + | |||
| ===== Order Routing ===== | ===== Order Routing ===== | ||
| Line 85: | Line 87: | ||
| The **OrderPull** message allows pulling multiple orders at once. | The **OrderPull** message allows pulling multiple orders at once. | ||
| </ | </ | ||
| + | |||
| + | ==== Routing Orders on Behalf of Another User ==== | ||
| + | |||
| + | Firms that trade on behalf of their own customers can submit, revise and pull orders for another user without that user being logged in. Set **OnBehalfOfUserName** to the **username** of the user the order belongs to. | ||
| + | |||
| + | The **UserId** field continues to identify the authenticated (routing) user - do not put the customer' | ||
| + | |||
| + | < | ||
| + | **OnBehalfOfUserName** is a username, not a user id. Leave it empty or omit it to trade as the authenticated user - existing applications are unaffected. | ||
| + | </ | ||
| + | |||
| + | Requirements: | ||
| + | |||
| + | * The authenticated (routing) user must have the **OrderRouting** role. This role is not enabled by default - a firm administrator must enable it on that user before any routed order will be accepted. | ||
| + | * The user named in **OnBehalfOfUserName** must belong to the authenticated user's firm or one of its child firms, and must be enabled and not deleted. | ||
| + | * The account must be one the named user is entitled to trade, and it must be subscribed by the authenticated session. | ||
| + | |||
| + | Example **OrderSubmit** on behalf of another user: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The same field is available on **OrderRevise** and **OrderPull**: | ||
| + | |||
| + | < | ||
| + | OrderPull { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | Pulls = [ | ||
| + | { | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | Supply **OnBehalfOfUserName** when revising or pulling a routed order as well. If it is omitted, the revision or cancellation is attributed to the authenticated user rather than to the user the order belongs to. | ||
| + | </ | ||
| + | |||
| + | Order validation - roles, entitled exchanges, accounts and permitted order types - is applied using the named user's own settings, not the authenticated user' | ||
| + | |||
| + | Order updates identify both parties, so routed activity remains fully attributable: | ||
| + | |||
| + | * **UserName** - the user the order belongs to. | ||
| + | * **RoutingUserName** - the authenticated user that submitted it. | ||
| + | |||
| + | If the named user cannot be resolved - an unknown username, a user outside the firm hierarchy, a disabled or deleted user, or an authenticated user without the **OrderRouting** role - the order is rejected with: | ||
| + | |||
| + | < | ||
| + | Specified user not found | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | Resolved users are cached, so changes to a routed user's roles, accounts or enabled state may not take effect immediately. | ||
| + | </ | ||
| + | |||
| Line 92: | Line 168: | ||
| - | ---- | ||
| ==== Market Order ==== | ==== Market Order ==== | ||
| Line 117: | Line 192: | ||
| - | ---- | ||
| - | === Limit Order === | + | |
| + | ==== Limit Order ==== | ||
| A Limit Order is submitted with a specific limit price. The order will only execute at the specified price or better. | A Limit Order is submitted with a specific limit price. The order will only execute at the specified price or better. | ||
| Line 143: | Line 218: | ||
| - | ---- | ||
| - | === Stop Order === | + | |
| + | ==== Stop Order ==== | ||
| A Stop Market Order becomes a Market Order when the stop price is reached. | A Stop Market Order becomes a Market Order when the stop price is reached. | ||
| Line 169: | Line 244: | ||
| - | ---- | ||
| - | === Stop Limit Order === | + | |
| + | ==== Stop Limit Order ==== | ||
| A Stop Limit Order becomes a Limit Order when the stop price is reached. | A Stop Limit Order becomes a Limit Order when the stop price is reached. | ||
| Line 196: | Line 271: | ||
| - | ---- | ||
| - | === Trailing Stop Order === | + | |
| + | ==== Trailing Stop Order ==== | ||
| A Trailing Stop Order moves the stop price automatically based on price movement. | A Trailing Stop Order moves the stop price automatically based on price movement. | ||
| Line 216: | Line 291: | ||
| | | ||
| | | ||
| - | TrailPrice | + | TrailDistance |
| } | } | ||
| ] | ] | ||
| Line 223: | Line 298: | ||
| - | ---- | ||
| - | === Fill or Kill (FOK) Order === | + | |
| + | ==== Fill or Kill (FOK) Order ==== | ||
| A Fill or Kill (FOK) Order must be executed immediately in full or it is canceled. | A Fill or Kill (FOK) Order must be executed immediately in full or it is canceled. | ||
| Line 249: | Line 324: | ||
| - | ---- | ||
| - | === Immediate or Cancel (IOC) Order === | + | |
| + | ==== Immediate or Cancel (IOC) Order ==== | ||
| An Immediate or Cancel (IOC) Order executes immediately for the available quantity and cancels the rest. | An Immediate or Cancel (IOC) Order executes immediately for the available quantity and cancels the rest. | ||
| Line 275: | Line 350: | ||
| - | ---- | ||
| - | === Good Till Canceled (GTC) Order === | + | |
| + | ==== Good Till Canceled (GTC) Order ==== | ||
| A Good Till Canceled (GTC) Order remains open until it is filled or explicitly canceled. | A Good Till Canceled (GTC) Order remains open until it is filled or explicitly canceled. | ||
| Line 301: | Line 376: | ||
| - | ---- | ||
| - | === Order Cancels Order (OCO) === | + | |
| + | ==== Order Cancels Order (OCO) ==== | ||
| An OCO (One Cancels Other) order is a pair of orders submitted together. Both orders are on the same side of the market: one is a Limit Order and the other is a Stop Order. When one fills, the other is automatically canceled. If one order is partially filled, the remaining volume of the other order is adjusted accordingly. | An OCO (One Cancels Other) order is a pair of orders submitted together. Both orders are on the same side of the market: one is a Limit Order and the other is a Stop Order. When one fills, the other is automatically canceled. If one order is partially filled, the remaining volume of the other order is adjusted accordingly. | ||
| Line 339: | Line 414: | ||
| - | ---- | ||
| - | === AutoOCO Order === | + | |
| + | ==== AutoOCO Order ==== | ||
| An AutoOCO Order is a batch of three orders: | An AutoOCO Order is a batch of three orders: | ||
| * A Trigger Order that initiates the trade. | * A Trigger Order that initiates the trade. | ||
| - | * Two OCO Orders (Take Profit and Stop Loss) that execute based on the trigger order' | + | * Two OCO Orders (Take Profit and Stop Loss) that are submitted with prices that are differentials to the fill price of the trigger order. |
| If the Trigger Order fills, the OCO Orders are submitted. If the OCO Orders begin filling, any remaining volume in the Trigger Order is canceled. | If the Trigger Order fills, the OCO Orders are submitted. If the OCO Orders begin filling, any remaining volume in the Trigger Order is canceled. | ||
| Example OrderSubmit message for an AutoOCO order: | Example OrderSubmit message for an AutoOCO order: | ||
| + | |||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== Take Profit and Stop Loss ==== | ||
| + | |||
| + | Take profit and stop loss orders are a type of OCO order. The first order in the batch is the **Trigger Order**. Once it fills, the **Take Profit** and **Stop Loss** orders are submitted. | ||
| + | |||
| + | Example OrderSubmit message for a Take Profit / Stop Loss order: | ||
| < | < | ||
| Line 356: | Line 513: | ||
| | | ||
| | | ||
| - | | + | |
| | | ||
| { | { | ||
| Line 370: | Line 527: | ||
| | | ||
| | | ||
| - | | + | |
| }, | }, | ||
| { | { | ||
| Line 377: | Line 534: | ||
| | | ||
| | | ||
| - | | + | |
| } | } | ||
| ] | ] | ||
| Line 383: | Line 540: | ||
| </ | </ | ||
| + | When the **Trigger Order** executes, the **Take Profit** and **Stop Loss** orders are placed. If the price reaches the take profit level, the stop loss order is canceled, and vice versa. | ||
| - | ---- | ||
| - | === Take Profit and Stop Loss === | + | ==== Flatten Position ==== |
| - | Take profit and stop loss orders are a type of OCO order. The first order in the batch is the **Trigger Order**. Once it fills, the **Take Profit** and **Stop Loss** orders are submitted. | + | A Flatten Position Order closes the entire position |
| - | Example | + | Example |
| < | < | ||
| Line 397: | Line 554: | ||
| | | ||
| | | ||
| - | | ||
| | | ||
| { | { | ||
| - | BuySell = BuySell.Buy, | + | |
| - | PriceType = PriceType.Limit, | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | }, | + | |
| - | { | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | }, | + | |
| - | { | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| } | } | ||
| ] | ] | ||
| Line 424: | Line 562: | ||
| </ | </ | ||
| - | When the **Trigger Order** executes, | + | < |
| + | The Flatten Position order automatically determines | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Order Status Summary Messages Reference ===== | ||
| + | When displaying order status to end users, combining the '' | ||
| + | ^ Order Status ^ Order Change ^ Status Summary Message ^ Notes ^ | ||
| + | | **Finished States** | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | Finished | '' | ||
| + | | **Rejected States** | ||
| + | | Rejected | '' | ||
| + | | Rejected | //(Other changes)// | " | ||
| + | | **Working States** | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | '' | ||
| + | | Working | //(Any change with fills)// | "{Base Message}, Partial Fill" | Appended when TotalFillVolume > 0 | | ||
| + | | **None (Pre-Submission) States** | ||
| + | | None | None | " | ||
| + | | None | '' | ||
| + | | None | '' | ||
| + | | None | '' | ||
| + | | None | '' | ||
| + | | **Held States** | ||
| + | | Held | //(Any)// | "Held on Server..." | ||