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 21:31] – chad | developers:websocket:orders [2025/03/14 22:10] (current) – chad | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ==== Order Routing ==== | + | ===== Order Routing |
| The WebSocket API provides real-time order routing, allowing clients to submit, revise, and pull orders. [[developers: | The WebSocket API provides real-time order routing, allowing clients to submit, revise, and pull orders. [[developers: | ||
| - | === Submitting an Order === | + | ==== Submitting an Order ==== |
| To submit an order, clients send an **OrderSubmit** message. | To submit an order, clients send an **OrderSubmit** message. | ||
| Line 36: | Line 36: | ||
| </ | </ | ||
| - | === Revising an Order === | + | |
| + | ==== Revising an Order ==== | ||
| To revise an existing order, clients send an **OrderRevise** message. | To revise an existing order, clients send an **OrderRevise** message. | ||
| Line 56: | Line 57: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | < | ||
| + | The **OrderRevise** message allows revising multiple orders at once. | ||
| + | </ | ||
| - | === Pulling (Cancelling) an Order === | + | ==== Pulling (Cancelling) an Order ==== |
| To cancel an order, clients must send an **OrderPull** message with the **order ID**. | To cancel an order, clients must send an **OrderPull** message with the **order ID**. | ||
| Line 77: | Line 82: | ||
| </ | </ | ||
| + | < | ||
| + | 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 { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 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 { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== Stop Order ==== | ||
| + | |||
| + | A Stop Market Order becomes a Market Order when the stop price is reached. | ||
| + | |||
| + | Example **Stop Order** message: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== Stop Limit Order ==== | ||
| + | |||
| + | A Stop Limit Order becomes a Limit Order when the stop price is reached. | ||
| + | |||
| + | Example **Stop Limit Order** message: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== Trailing Stop Order ==== | ||
| + | |||
| + | A Trailing Stop Order moves the stop price automatically based on price movement. | ||
| + | |||
| + | Example **Trailing Stop Order** message: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 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 { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 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 { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 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 { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 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. | ||
| + | |||
| + | OCO orders must be placed for the **same Market and Account**. | ||
| + | |||
| + | Example OrderSubmit message for an OCO order: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Both orders are placed at the same time. If the Limit Order is filled, the Stop Order is automatically canceled, and vice versa. | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== AutoOCO Order ==== | ||
| + | |||
| + | An AutoOCO Order is a batch of three orders: | ||
| + | * A Trigger Order that initiates the trade. | ||
| + | * Two OCO Orders (Take Profit and Stop Loss) that execute based on 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. | ||
| + | |||
| + | Example OrderSubmit message for an AutoOCO order: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 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: | ||
| + | |||
| + | < | ||
| + | OrderSubmit { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | 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. | ||