> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anchorage.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Submitting orders

> Submit, cancel, and resend orders over a WebSocket session.

export const Check = () => <Icon icon="check" color="#049159" />;
export const Cross = () => <Icon icon="x" color="#dd0000" />;

## NewOrderSingle

A `NewOrderSingle` message allows a user to submit an order and receive execution reports over the same WebSocket session. Currently `MARKET` and `LIMIT` order types are supported.

**Example request:**

```json theme={null}
{
  "messageType": "NewOrderSingle",
  "timestamp": "2023-03-12T22:22:09.925952Z",
  "payload": {
    "clOrderId": "47ce2580-5e57-45d8-b67f-71a5aa55d05f",
    "symbol": "BTC-USD",
    "side": "SELL",
    "currency": "USD",
    "quantity": "10000",
    "orderType": "LIMIT",
    "limitPrice": "21000",
    "timeInForce": "GTC",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10"
  }
}
```

**Example response:**

```json theme={null}
{
  "messageType": "ExecutionReport",
  "timestamp": "2023-03-12T22:22:09.925952Z",
  "version": "1.0",
  "seqNum": 3,
  "payload": {
    "clOrderId": "47ce2580-5e57-45d8-b67f-71a5aa55d05f",
    "orderId": "99b60f12-a20c-4977-99ea-f9affdb8e5f2",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "symbol": "BTC-USD",
    "orderQty": "1000",
    "side": "SELL",
    "currency": "USD",
    "orderType": "LIMIT",
    "limitPrice": "21000",
    "timeInForce": "GTC",
    "orderStatus": "FILLED",
    "execId": "58fd5afc-b85e-45d1-951e-d6429ea9cd54",
    "execType": "FILL",
    "avgPx": "21990.01",
    "avgPxAllIn": "21968.02",
    "cumQty": "10000",
    "fillPx": "21990.01",
    "fillQty": "10000",
    "leavesQty": "0",
    "cancelQty": "0",
    "fee": "0.00045521",
    "feeCurrency": "BTC",
    "submitTime": "2023-03-12T22:22:09.909251Z",
    "transactTime": "2023-03-12T22:22:09.925050Z"
  }
}
```

**Example reject response:**

```json theme={null}
{
  "messageType": "ExecutionReport",
  "timestamp": "2023-03-12T22:22:09.925952Z",
  "version": "1.0",
  "seqNum": 5,
  "payload": {
    "clOrderId": "47ce2580-5e57-45d8-b67f-71a5aa55d05f",
    "orderId": "99b60f12-a20c-4977-99ea-f9affdb8e5f2",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "symbol": "BTC-USD",
    "orderQty": "1000",
    "side": "SELL",
    "currency": "USD",
    "orderType": "LIMIT",
    "limitPrice": "21000",
    "timeInForce": "GTC",
    "orderStatus": "REJECTED",
    "execId": "6a33f72c-ec2e-4c7a-b443-29de3f884145",
    "execType": "REJECT",
    "avgPx": "0",
    "avgPxAllIn": "0",
    "cumQty": "0",
    "fillPx": "0",
    "fillQty": "0",
    "leavesQty": "0",
    "cancelQty": "0",
    "rejectReason": "Invalid request",
    "rejectReasonText": "invalid price: 21500.0001, must be multiplication of 0.01",
    "fee": "0",
    "feeCurrency": "",
    "submitTime": "2023-03-12T22:22:09.909251Z",
    "transactTime": "2023-03-12T22:22:09.925050Z"
  }
}
```

### Request parameters

| Parameter     | Type                          | Required  | Description                                                                   |
| ------------- | ----------------------------- | --------- | ----------------------------------------------------------------------------- |
| `messageType` | string                        | <Check /> | `NewOrderSingle`                                                              |
| `timestamp`   | string (date-time)            | <Check /> | RFC3990 date-time string                                                      |
| `clOrderId`   | string                        | <Check /> | Client order ID, must be unique; recommend UUID                               |
| `accountId`   | string                        | <Check /> | Anchorage brokerage account ID                                                |
| `symbol`      | string                        | <Check /> | Trading symbol, e.g. `"BTC-USD"`                                              |
| `side`        | `"BUY"` \| `"SELL"`           | <Check /> | Side for the order                                                            |
| `orderQty`    | string                        | <Check /> | Order quantity                                                                |
| `currency`    | string                        | <Check /> | Currency the order quantity is specified in; can be either side of the symbol |
| `orderType`   | `"MARKET"` \| `"LIMIT"`       | <Check /> | Order type                                                                    |
| `limitPrice`  | string                        | <Cross /> | Limit price; required if `orderType` is `LIMIT`                               |
| `timeInForce` | `"FOK"` \| `"GTC"` \| `"IOC"` | <Cross /> | FOK = Fill Or Kill, GTC = Good Till Cancel, IOC = Immediate Or Cancel         |

### Response parameters

| Parameter          | Type                          | Required  | Description                                                                              |
| ------------------ | ----------------------------- | --------- | ---------------------------------------------------------------------------------------- |
| `messageType`      | string                        | <Check /> | `ExecutionReport`                                                                        |
| `timestamp`        | string (date-time)            | <Check /> | RFC3990 date-time string                                                                 |
| `clOrderId`        | string                        | <Check /> | Client order ID as specified on the order request                                        |
| `orderId`          | string                        | <Check /> | Anchorage order ID                                                                       |
| `accountId`        | string                        | <Check /> | Anchorage brokerage account ID                                                           |
| `symbol`           | string                        | <Check /> | Trading symbol as specified on the order request                                         |
| `side`             | `"BUY"` \| `"SELL"`           | <Check /> | Order side as specified on the order request                                             |
| `orderQty`         | string                        | <Check /> | Order quantity as specified on the order request                                         |
| `currency`         | string                        | <Check /> | Currency as specified on the order request                                               |
| `orderType`        | `"MARKET"` \| `"LIMIT"`       | <Check /> | Order type as specified on the order request                                             |
| `limitPrice`       | string                        | <Cross /> | Limit price as specified on the order request                                            |
| `timeInForce`      | `"FOK"` \| `"GTC"` \| `"IOC"` | <Cross /> | Time in force as specified on the order request                                          |
| `orderStatus`      | string                        | <Check /> | `PENDING`, `NEW`, `REJECTED`, `PENDING_CANCEL`, `CANCELED`, `FILLED`, `PARTIALLY_FILLED` |
| `execId`           | string                        | <Cross /> | Execution ID, can be used to query for trades                                            |
| `execType`         | string                        | <Cross /> | `NEW`, `FILL`, `CANCEL`, `REJECT`, `CANCEL_REJECT`                                       |
| `avgPx`            | string                        | <Cross /> | Average price of filled portion of the order                                             |
| `avgPxAllIn`       | string                        | <Cross /> | Average price including fees of filled portion                                           |
| `cumQty`           | string                        | <Check /> | Cumulative quantity filled                                                               |
| `fillPx`           | string                        | <Cross /> | Fill quantity of this execution (`execType="FILL"`)                                      |
| `fillQty`          | string                        | <Cross /> | Fill price of this execution (excluding fees)                                            |
| `leavesQty`        | string                        | <Check /> | Leaves quantity of this order                                                            |
| `cancelQty`        | string                        | <Cross /> | Canceled quantity of this order                                                          |
| `fee`              | string                        | <Cross /> | Anchorage commission charged for this execution                                          |
| `feeCurrency`      | string                        | <Cross /> | Currency that the commission is charged in                                               |
| `rejectReason`     | string                        | <Cross /> | Reason for rejection                                                                     |
| `rejectReasonText` | string                        | <Cross /> | Additional description for reason of reject                                              |
| `submitTime`       | string (date-time)            | <Check /> | Order submission time in RFC3990 format                                                  |
| `transactTime`     | string (date-time)            | <Cross /> | Transaction time in RFC3990 format                                                       |

***

## CancelOrderRequest

Cancel an order. `origClOrderId` and `accountId` must match the original order request. `orderId` must match the order ID returned on execution reports.

Cancel requests on any completed order will be rejected.

**Example cancel request:**

```json theme={null}
{
  "messageType": "OrderCancelRequest",
  "timestamp": "2023-03-12T22:22:09.925952Z",
  "payload": {
    "origClOrderId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "orderId": "0d479b19-1012-42d1-9558-ffb4d8db7153",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10"
  }
}
```

**Example response:**

```json theme={null}
{
  "messageType": "ExecutionReport",
  "timestamp": "2023-03-13T13:44:05.244315Z",
  "version": "1.0",
  "seqNum": 9,
  "payload": {
    "clOrderId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "orderId": "0d479b19-1012-42d1-9558-ffb4d8db7153",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "symbol": "BTC-USD",
    "side": "SELL",
    "orderQty": "10000",
    "currency": "USD",
    "orderType": "LIMIT",
    "limitPrice": "23500",
    "timeInForce": "GTC",
    "orderStatus": "CANCELED",
    "cumQty": "0",
    "cancelQty": "10000",
    "leavesQty": "0",
    "execId": "7cfcbb67-76fa-46c3-8535-655fd8fe0eb8",
    "execType": "CANCEL",
    "submitTime": "2023-03-13T13:44:05.182005Z",
    "transactTime": "2023-03-13T13:44:05.185177Z"
  }
}
```

**Example cancel reject response:**

```json theme={null}
{
  "messageType": "ExecutionReport",
  "timestamp": "2023-03-13T13:59:01.668938Z",
  "payload": {
    "clOrderId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "orderId": "0d479b19-1012-42d1-9558-ffb4d8db7153",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "symbol": "BTC-USD",
    "side": "SELL",
    "orderQty": "10000",
    "currency": "USD",
    "orderType": "LIMIT",
    "limitPrice": "23500",
    "timeInForce": "GTC",
    "orderStatus": "NEW",
    "execId": "16532303-8478-4a6e-82db-5920e6553525",
    "execType": "CANCEL_REJECT",
    "avgPx": "0",
    "avgPxAllIn": "0",
    "cancelQty": "0",
    "cumQty": "0",
    "leavesQty": "10000",
    "rejectReason": "Invalid account",
    "rejectReasonText": "Invalid account id for cancel request",
    "submitTime": "2023-03-13T13:59:00.151982Z",
    "transactTime": "2023-03-13T13:59:01.668610Z"
  }
}
```

### Request parameters

| Parameter       | Type               | Required  | Description                                                      |
| --------------- | ------------------ | --------- | ---------------------------------------------------------------- |
| `messageType`   | string             | <Check /> | `OrderCancelRequest`                                             |
| `timestamp`     | string (date-time) | <Check /> | RFC3990 date-time string                                         |
| `origClOrderId` | string             | <Check /> | Client order ID as specified on the order request                |
| `orderId`       | string             | <Check /> | Anchorage order ID                                               |
| `accountId`     | string             | <Check /> | Anchorage brokerage account ID as specified on the order request |

**Response:** See response parameters for [NewOrderSingle](#newordersingle).

***

## ExecutionReportResendRequest

Resend execution reports for an order. Allows a client to request execution reports for a live or completed order. If the order is completed, all previous execution reports are sent again. If the order is still alive, in addition to any previous execution reports, newer reports will be streamed on this WebSocket as they occur.

Use this to synchronize order states after a WebSocket disconnect.

**Example resend request:**

```json theme={null}
{
  "messageType": "ExecutionReportResendRequest",
  "timestamp": "2023-03-12T22:22:09.925952Z",
  "payload": {
    "origClOrderId": "3fa8372d-b51d-44ab-a456-43e947e4be10",
    "orderId": "0d479b19-1012-42d1-9558-ffb4d8db7153",
    "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10"
  }
}
```

### Request parameters

| Parameter       | Type               | Required  | Description                                                      |
| --------------- | ------------------ | --------- | ---------------------------------------------------------------- |
| `messageType`   | string             | <Check /> | `ExecutionReportResendRequest`                                   |
| `timestamp`     | string (date-time) | <Check /> | RFC3990 date-time string                                         |
| `origClOrderId` | string             | <Check /> | Client order ID as specified on the order request                |
| `orderId`       | string             | <Check /> | Anchorage order ID                                               |
| `accountId`     | string             | <Check /> | Anchorage brokerage account ID as specified on the order request |

**Response:** A stream of execution reports. See response parameters for [NewOrderSingle](#newordersingle).
