developers:websocket:orders

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
developers:websocket:orders [2025/03/14 22:10] chaddevelopers:websocket:orders [2026/03/05 16:43] (current) – [AutoOCO Order] frank
Line 344: Line 344:
 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'fill price.+  * 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:
 +
 +<code>
 +{
 +  "UserId": "",
 +  "HasUserId": false,
 +  "AccountId": "60B90323-E72A-4BBF-A129-3882019E622C",
 +  "MarketId": "XCME_Eq ES (H26)",
 +  "OrderLink": 2,
 +  "ManualOrderIndicator": true,
 +  "Orders": [
 +    {
 +      "BuySell": 1,
 +      "PriceType": 1,
 +      "TimeType": 0,
 +      "Volume": 1,
 +      "MaxShow": 0,
 +      "HasMaxShow": false,
 +      "MaxVolume": 0,
 +      "HasMaxVolume": false,
 +      "LimitPrice": {
 +        "Value": "685800"
 +      },
 +      "StopPrice": null,
 +      "TrailDistance": null,
 +      "Tag": "",
 +      "HasTag": false,
 +      "ActivationType": 0,
 +      "HasActivationType": false,
 +      "ActivationData": null
 +    },
 +    {
 +      "BuySell": -1,
 +      "PriceType": 1,
 +      "TimeType": 2,
 +      "Volume": 0,
 +      "MaxShow": 0,
 +      "HasMaxShow": false,
 +      "MaxVolume": 0,
 +      "HasMaxVolume": false,
 +      "LimitPrice": {
 +        "Value": "250"
 +      },
 +      "StopPrice": null,
 +      "TrailDistance": null,
 +      "Tag": "",
 +      "HasTag": false,
 +      "ActivationType": 1,
 +      "HasActivationType": true,
 +      "ActivationData": null
 +    },
 +    {
 +      "BuySell": -1,
 +      "PriceType": 2,
 +      "TimeType": 2,
 +      "Volume": 0,
 +      "MaxShow": 0,
 +      "HasMaxShow": false,
 +      "MaxVolume": 0,
 +      "HasMaxVolume": false,
 +      "LimitPrice": null,
 +      "StopPrice": {
 +        "Value": "125"
 +      },
 +      "TrailDistance": null,
 +      "Tag": "",
 +      "HasTag": false,
 +      "ActivationType": 1,
 +      "HasActivationType": true,
 +      "ActivationData": null
 +    }
 +  ]
 +}
 +</code>
 +
 +
 +
 +
 +==== 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:
  
 <code> <code>
Line 355: Line 437:
    AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620",    AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620",
    MarketId = "XCME_C ZC (H25)",    MarketId = "XCME_C ZC (H25)",
-   OrderLink = OrderLink.AutoOCO,+   OrderLink = OrderLink.OCO,
    Orders = [    Orders = [
       {       {
Line 369: Line 451:
          TimeType = TimeType.Normal,          TimeType = TimeType.Normal,
          Volume = 0,          Volume = 0,
-         LimitPrice = "2380.00"+         LimitPrice = "2385.00"
       },       },
       {       {
Line 376: Line 458:
          TimeType = TimeType.Normal,          TimeType = TimeType.Normal,
          Volume = 0,          Volume = 0,
-         StopPrice = "2365.00"+         StopPrice = "2360.00"
       }       }
    ]    ]
Line 382: Line 464:
 </code> </code>
  
 +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.
  
  
 +==== Flatten Position ====
  
-==== Take Profit and Stop Loss ====+A Flatten Position Order closes the entire position in the specified market by submitting an offsetting order at market price.
  
-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 **Flatten Position Order** message:
- +
-Example OrderSubmit message for a Take Profit / Stop Loss order:+
  
 <code> <code>
Line 396: Line 478:
    AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620",    AccountId = "448c9ddd-6a50-4852-85ea-aad3b6d60620",
    MarketId = "XCME_C ZC (H25)",    MarketId = "XCME_C ZC (H25)",
-   OrderLink = OrderLink.OCO, 
    Orders = [    Orders = [
       {       {
-         BuySell = BuySell.Buy, +         PriceType = PriceType.Flatten
-         PriceType = PriceType.Limit, +
-         TimeType = TimeType.Normal, +
-         Volume = 1, +
-         LimitPrice = "2375.00" +
-      }, +
-      { +
-         BuySell = BuySell.Sell, +
-         PriceType = PriceType.Limit, +
-         TimeType = TimeType.Normal, +
-         Volume = 0, +
-         LimitPrice = "2385.00" +
-      }, +
-      { +
-         BuySell = BuySell.Sell, +
-         PriceType = PriceType.StopMarket, +
-         TimeType = TimeType.Normal, +
-         Volume = 0, +
-         StopPrice = "2360.00"+
       }       }
    ]    ]
Line 423: Line 486:
 </code> </code>
  
-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.+<bootnote> 
 +The Flatten Position order automatically determines the correct side (Buy/Sell) and volume based on the current position.  Clip size limits are ignored to ensure the entire position is closed. 
 +</bootnote> 
 + 
 + 
 +===== Order Status Summary Messages Reference =====
  
 +When displaying order status to end users, combining the ''OrderStatus'' and <del>OrderChange</del> fields provides more meaningful feedback than either field alone. The following table maps these field combinations to user-friendly status messages.
  
 +^ Order Status ^ Order Change ^ Status Summary Message ^ Notes ^
 +| **Finished States**  ||||
 +| Finished | ''PullFailed'', ''PullRejected'', ''PullRiskFailed'' | "Cancel Failed" | Includes StatusDetail |
 +| Finished | ''PullSuccess'', ''PullSent'', ''PullRiskSuccess'' //(with fills)// | "Completed, Partial Fill" | When TotalFillVolume ≠ 0 |
 +| Finished | ''PullSuccess'', ''PullSent'', ''PullRiskSuccess'' //(no fills)// | "Canceled" | When TotalFillVolume = 0 |
 +| Finished | ''TradeCompleted'' //(partial)// | "Completed, Partial Fill" | When TotalFillVolume < CurrentVolume |
 +| Finished | ''TradeCompleted'' //(full)// | "Completed, Filled" | When TotalFillVolume = CurrentVolume |
 +| Finished | ''StatusRequestFailed'', ''StatusRequestRejected'', ''StatusRequestRiskFailed'', ''StatusRequestRiskSuccess'', ''StatusRequestSent'', ''StatusRequestSuccess'', ''TagFailed'', ''TagSuccess'' //(partial)// | "Completed, Partial Fill, {OrderChange}" | When TotalFillVolume < CurrentVolume |
 +| Finished | ''StatusRequestFailed'', ''StatusRequestRejected'', ''StatusRequestRiskFailed'', ''StatusRequestRiskSuccess'', ''StatusRequestSent'', ''StatusRequestSuccess'', ''TagFailed'', ''TagSuccess'' //(full)// | "Completed, Filled, {OrderChange}" | When TotalFillVolume = CurrentVolume |
 +| Finished | ''RevisionRiskFailed'' //(filled)// | "Completed, Filled, {OrderChange}" | When TotalFillVolume = CurrentVolume |
 +| Finished | ''TradeBusted'' | "Completed, {OrderChange}" | |
 +| Finished | ''SubmissionSuccess'' //(RFQ only)// | "Completed" | Only for PriceType.RFQ |
 +| **Rejected States**  ||||
 +| Rejected | ''StatusRequestFailed'', ''StatusRequestRejected'', ''StatusRequestRiskFailed'', ''StatusRequestRiskSuccess'', ''StatusRequestSent'', ''StatusRequestSuccess'' | "Rejected, {OrderChange}" | Includes StatusDetail |
 +| Rejected | //(Other changes)// | "Rejected" | Includes StatusDetail |
 +| **Working States**  ||||
 +| Working | ''PullRiskSuccess'', ''PullSent'', ''PullSuccess'' | "Canceling..." | |
 +| Working | ''RevisionSent'', ''RevisionRiskSuccess'' | "Revising..." | |
 +| Working | ''RevisionSuccess'' | "Working, Revised" | |
 +| Working | ''RevisionFailed'', ''RevisionRejected'', ''RevisionRiskFailed'' | "Working, Revision Failed" | Includes StatusDetail |
 +| Working | ''PullFailed'', ''PullRejected'', ''PullRiskFailed'' | "Working, Cancel Failed" | Includes StatusDetail |
 +| Working | ''Trade'', ''SubmissionSent'', ''SubmissionSuccess'', ''SubmissionRiskSuccess'' | "Working..." | |
 +| Working | ''Handover'' | "Working, Handover" | |
 +| Working | ''Rollover'' | "Working, Rollover" | |
 +| Working | ''StatusRequestFailed'', ''StatusRequestRejected'', ''StatusRequestRiskFailed'', ''StatusRequestRiskSuccess'', ''StatusRequestSent'', ''StatusRequestSuccess'', ''TagFailed'', ''TagSuccess'' | "Working, {OrderChange}" | |
 +| Working | //(Any change with fills)// | "{Base Message}, Partial Fill" | Appended when TotalFillVolume > 0 |
 +| **None (Pre-Submission) States**  ||||
 +| None | None | "Submitting..." | |
 +| None | ''SubmissionRiskSuccess'' | "Submitting to Exchange" | |
 +| None | ''SubmissionRejected'', ''SubmissionRiskRejected'' | "Submission Rejected" | |
 +| None | ''SubmissionFailed'' | "Submission Failed" | |
 +| None | ''SubmissionSent'', ''SubmissionSuccess'' | "Submission Sent" | |
 +| **Held States**  ||||
 +| Held | //(Any)// | "Held on Server..." (Real Market) \\ "Held on Client..." (Non-Real Market) | |
  • developers/websocket/orders.1741990207.txt.gz
  • Last modified: 2025/03/14 22:10
  • by chad