# Enumerations

Reference for every enumeration the **order entry protocol** uses.

---

## Order Type

The kind of order being placed.

{.compact}

| Value                 | Description                                          | Price Required | Trigger Price |
|-----------------------|------------------------------------------------------|----------------|---------------|
| **LIMIT**             | Standard limit order                                 | Yes            | No            |
| **MARKET**            | Market order, executes at best available price       | No             | No            |
| **STOP_MARKET**       | Becomes a market order at the stop price             | Yes            | No            |
| **STOP_LIMIT**        | Becomes a limit order when the trigger price is hit  | Yes            | Yes           |
| **MARKET_IF_TOUCHED** | Becomes a market order when the trigger price is hit | No             | Yes           |
| **LIMIT_IF_TOUCHED**  | Becomes a limit order when the trigger price is hit  | Yes            | Yes           |
| **MARKET_PEGGED**     | Pegged to market price with offset                   | No             | No            |
| **PRIMARY_PEGGED**    | Pegged to primary (mid) price with offset            | No             | No            |

For `STOP_MARKET`, the stop trigger is encoded in the `price` field rather
than `triggerPrice`. The other stop and trigger variants populate
`triggerPrice` and use `price` for the resulting limit price.

---

## Time in Force

How long the order stays active.

{.compact}

| Value                   | Abbreviation | Description                                               |
|-------------------------|--------------|-----------------------------------------------------------|
| **GOOD_TILL_CANCEL**    | GTC          | Order remains active until filled or explicitly cancelled |
| **DAY**                 | DAY          | Order expires at the end of the trading day               |
| **IMMEDIATE_OR_CANCEL** | IOC          | Fill immediately what's available, cancel the rest        |
| **FILL_OR_KILL**        | FOK          | Fill the entire order immediately or cancel it completely |

---

## Order Side

The side of the order.

{.compact}

| Value   | Description |
|---------|-------------|
| **BID** | Buy order   |
| **ASK** | Sell order  |

---

## Order State

The current state of an order in its lifecycle.

{.compact}

| State              | Description                                                    |
|--------------------|----------------------------------------------------------------|
| **DISCARDED**      | Order was discarded before reaching the exchange               |
| **PENDING_NEW**    | Order has been submitted but not yet confirmed by the exchange |
| **CONFIRMED**      | Order is active on the exchange order book                     |
| **FILLED**         | Order has been completely filled                               |
| **PENDING_AMEND**  | Order modification is pending confirmation                     |
| **PENDING_CANCEL** | Order cancellation is pending confirmation                     |
| **CANCELED**       | Order has been cancelled                                       |
| **REJECTED**       | Order was rejected internally or by the exchange               |

Typical state flows:

1. **Successful placement**: PENDING_NEW → CONFIRMED.
2. **Modification**: CONFIRMED → PENDING_AMEND → CONFIRMED.
3. **Cancellation**: CONFIRMED → PENDING_CANCEL → CANCELED.
4. **Execution**: CONFIRMED → FILLED.
5. **Placement rejection**: PENDING_NEW → REJECTED.
6. **Pre-validation discard**: PENDING_NEW → DISCARDED.

---

## Open / Close

Whether an order opens or closes a position. Only meaningful for
exchanges with isolated positions.

{.compact}

| Value     | Description                                                 |
|-----------|-------------------------------------------------------------|
| **OPEN**  | Order opens a new position                                  |
| **CLOSE** | Order closes an existing position                           |
| **AUTO**  | Automatically determined (not supported by trading adapter) |

> [!NOTE]
> Only applicable for instruments with isolated positions. Set to `null`
> for instruments with non-isolated positions.

---

## Status Type

State of an account's order-entry operations.

{.compact}

| Status                 | Description                                                                                                                      |
|------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| **OK**                 | Normal operation, orders can be placed                                                                                           |
| **DISCONNECTED**       | Connection to exchange lost, operations will fail                                                                                |
| **EXCHANGE_BUSY**      | Exchange is rate-limiting or otherwise busy                                                                                      |
| **BLOCKED**            | Account is blocked on the exchange                                                                                               |
| **BANNED**             | Account is banned on the exchange                                                                                                |
| **UNASSIGNED**         | Account was unassigned from trading adapter at runtime; order placements and modifications are rejected until teardown completes |
| **MANUAL_SHUTDOWN**    | Manual shutdown in progress                                                                                                      |
| **EMERGENCY_SHUTDOWN** | Emergency shutdown activated                                                                                                     |

---

## Wallet Type

The type of wallet or margin account.

{.compact}

| Type                  | Applicable Exchanges | Description                                              |
|-----------------------|----------------------|----------------------------------------------------------|
| **ACCOUNT**           | All                  | Default account wallet                                   |
| **SPOT**              | Multiple             | Spot trading wallet                                      |
| **CROSS_MARGIN**      | Multiple             | Cross-margin wallet (collateral shared across positions) |
| **ISOLATED_MARGIN**   | Multiple             | Isolated margin wallet (collateral per position)         |
| **INVERSE**           | Bybit                | Inverse perpetual contracts                              |
| **DERIVATIVES**       | Bitfinex             | Derivatives trading wallet                               |
| **SPOT_MARGIN**       | Bitfinex             | Spot margin trading wallet                               |
| **MULTI_COLLATERAL**  | Kraken Futures       | Multi-asset collateral wallet                            |
| **SINGLE_COLLATERAL** | Kraken Futures       | Single-asset collateral wallet                           |
| **COIN_MARGIN**       | Binance              | Coin-margined contracts (Portfolio Margin)               |
| **USDT_MARGIN**       | Binance, Bitget      | USDT-margined contracts                                  |
| **USDC_MARGIN**       | Bitget               | USDC-margined contracts                                  |
| **USDT_PERP**         | Gate.io              | USDT perpetual futures                                   |
| **BTC_PERP**          | Gate.io              | BTC perpetual futures                                    |
| **DELIVERY**          | Gate.io              | Delivery futures                                         |
| **FUND**              | BingX                | Non-trading wallet for on-chain deposits and withdrawals |

---

## Wallet Margin Type

The margin characteristics of a wallet.

{.compact}

| Type                | Description                                           |
|---------------------|-------------------------------------------------------|
| **NOT_IMPLEMENTED** | Specific handling for margin type not implemented     |
| **NO_MARGIN**       | No margin trading (e.g., spot trading without margin) |
| **ISOLATED**        | Collateral is isolated per position                   |
| **CROSS**           | Collateral is shared across all positions             |

---

## Maintenance Margin Type

How maintenance margin information is provided.

{.compact}

| Type          | Description                                             |
|---------------|---------------------------------------------------------|
| **NONE**      | Maintenance margin not available for this wallet type   |
| **GLOBAL**    | Available as a total USD quantity for the entire wallet |
| **PER_ASSET** | Available for each individual asset in the wallet       |

---

## Error Source

Where an error originated.

{.compact}

| Source       | Description                                 |
|--------------|---------------------------------------------|
| **INTERNAL** | Error originated within the Trading Adapter |
| **EXCHANGE** | Error was reported by the exchange          |

---

## Order Error Type

Type of error returned for an order operation.

{.compact}

| Error Type                            | Description                                              |
|---------------------------------------|----------------------------------------------------------|
| **ORDER_GONE**                        | Order already filled or cancelled                        |
| **ORDER_INVALID**                     | Order parameters are invalid                             |
| **ORDER_NOT_FOUND**                   | Order does not exist on exchange                         |
| **ORDER_STATE_INVALID**               | Order is in a state that prevents this operation         |
| **ORDER_NOT_CHANGED**                 | Order amendment did not result in any changes            |
| **ORDER_ID_DUPLICATE**                | Order ID is already in use                               |
| **ORDER_NOT_SUPPORTED**               | Order type or parameters not supported                   |
| **ORDER_AMEND_NOT_AS_REQUESTED**      | Order was amended but not as requested                   |
| **NO_CONNECTION_TO_EXCHANGE**         | Connection to exchange is down                           |
| **HTTP_REQUEST_FAILED**               | HTTP request failed                                      |
| **HTTP_REQUEST_TIMEOUT**              | HTTP request timed out                                   |
| **ACCOUNT_NOT_LOGGED_IN**             | Account must login first                                 |
| **ACCOUNT_INVALID**                   | Account credentials or configuration invalid             |
| **ACCOUNT_NOT_FOUND**                 | Account does not exist                                   |
| **ACCOUNT_AUTHENTICATION_FAILED**     | Authentication failed                                    |
| **ACCOUNT_BALANCE_INSUFFICIENT**      | Insufficient funds for order                             |
| **UNAVAILABLE**                       | Service temporarily unavailable                          |
| **ACCESS_DENIED**                     | Access denied by exchange                                |
| **RATE_LIMIT_EXCEEDED**               | Rate limit threshold reached (check `retryTimeNs`)       |
| **RATE_LIMIT_BLOCKED_AFTER_EXCEEDED** | Blocked after exceeding rate limits (check `retryTimeNs`)|
| **RISK_LIMIT_EXCEEDED**               | Order would breach a configured risk limit               |
| **INSTRUMENT_UNKNOWN**                | Instrument not recognised                                |
| **UNEXPECTED_RESPONSE**               | Unexpected response from exchange                        |

> [!TIP]
> `RATE_LIMIT_EXCEEDED` and `RATE_LIMIT_BLOCKED_AFTER_EXCEEDED` populate
> `retryTimeNs` with the earliest time it makes sense to retry. Wait
> until that time before retrying so you don't burn more rate-limit
> budget for nothing.

---

## Login Error Type

Errors that can occur during login.

{.compact}

| Error Type                | Description                                            |
|---------------------------|--------------------------------------------------------|
| **ACCOUNT_NOT_FOUND**     | Account does not exist in the system                   |
| **AUTHENTICATION_FAILED** | Exchange authentication failed                         |
| **SUBSCRIPTION_FAILED**   | Failed to subscribe to account data feeds              |
| **UNEXPECTED_RESPONSE**   | Unexpected response from exchange during login         |
| **UNAVAILABLE**           | Login temporarily unavailable                          |
| **UNASSIGNED**            | Account was unassigned from trading adapter at runtime |

---

## Fill Error Type

Errors that can occur on fill-context operations.

{.compact}

| Error Type                | Description                                   |
|---------------------------|-----------------------------------------------|
| **FILL_NOT_FOUND**        | Requested fill does not exist                 |
| **ACCOUNT_NOT_LOGGED_IN** | Account must be logged in to access fill data |

---

## Fill Type

Where a fill came from.

{.compact}

| Type           | Description                                                                      |
|----------------|----------------------------------------------------------------------------------|
| **ORDER_FILL** | Fill resulted from an order placed by the user                                   |
| **OTHER**      | Fill did not result from a user order (e.g., liquidations, unwinds, settlements) |

---

## See Also

- [Protocol](protocol.md). Protocol specification with message formats.
- [Concepts](concepts.md). Core concepts and conventions.
