# Order Types and Fields

Reference for the types and fields used when building order transactions. For the signing and submission flow,
see [Transaction Signing](./tx-signing.md). For decimal encoding, see [Decimal Encoding](./decimal-encoding.md).

## Order Types

| Variant             | Behavior                                                                                   |
|---------------------|--------------------------------------------------------------------------------------------|
| `Limit`             | standard limit order, rests on the book until filled or cancelled                          |
| `PostOnly`          | rejected if it would immediately match (guarantees maker execution)                        |
| `FillOrKill`        | must fill entirely in one match or the entire order is cancelled                           |
| `ImmediateOrCancel` | fills as much as possible immediately, cancels any remaining size                          |
| `PostOnlySlide`     | if the limit price would cross, slides to the best non-crossing price instead of rejecting |
| `PostOnlyFront`     | posts at the front of the queue at the best price that doesn't cross                       |

## NewOrderArgs

| Field              | Type                       | Description                                                                                |
|--------------------|----------------------------|--------------------------------------------------------------------------------------------|
| `price`            | `SurrogateDecimal`         | order price — see [Decimal Encoding](./decimal-encoding.md)                                |
| `size`             | `SurrogateDecimal`         | order size                                                                                 |
| `side`             | `Side`                     | `Bid` (buy) or `Ask` (sell)                                                                |
| `order_type`       | `OrderType`                | one of the order types above                                                               |
| `reduce_only`      | `bool`                     | if `true`, can only reduce an existing position — rejected if it would open or increase one |
| `client_order_id`  | `Option<ClientOrderId>`    | optional user-defined u64 identifier; returned in order updates and usable for cancels     |
| `pending_tpsl_pair`| `Option<PendingTpslPair>`  | optional take-profit / stop-loss pair attached to the order                                |

## Take-Profit / Stop-Loss (TP/SL)

A `PendingTpslPair` attaches conditional exit orders to a placement. Each leg is optional:

| Field              | Type               | Description                                                                |
|--------------------|--------------------|----------------------------------------------------------------------------|
| `take_profit`      | `Option<TpslLeg>`  | triggers when price reaches the target                                     |
| `stop_loss`        | `Option<TpslLeg>`  | triggers when price hits the stop level                                    |
| `dynamic_size`     | `bool`             | if `true`, the TP/SL size tracks the current position size at trigger time |

Each `TpslLeg` contains:

| Field               | Type                       | Description                                                      |
|----------------------|----------------------------|------------------------------------------------------------------|
| `trigger_price`      | `SurrogateDecimal`        | price at which the leg activates                                 |
| `order_price`        | `Option<SurrogateDecimal>`| limit price for the triggered order; `None` for market execution |
| `trigger_condition`  | `TriggerPriceCondition`   | `Mark` (mark price), `Oracle` (oracle price), or `LastTrade`    |

## Sub-Account Index

All call structs include a `sub_account_index: Option<u8>` field. This is reserved for future sub-account
support. Set it to `None` for now.
