Submit order
NewOrderSingle
A NewOrderSingle message allows user to submit an order and receive execution reports over the same websocket session.
Currently MARKET and LIMIT order types are supported.
Example new order request:
{
"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:
{
"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:
{
"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 | Yes | NewOrderSingle |
| timestamp | string (date-time) | Yes | RFC3990 date-time string |
| clOrderId | string | Yes | Client order ID, must be unique, recommed UUID |
| accountId | string | Yes | Anchorage brokerage account ID |
| symbol | string | Yes | Trading symbol for the order, e.g. "BTC-USD" |
| side | ["BUY", "SELL"] | Yes | Side for the order, BUY or SELL |
| orderQty | string | Yes | Order quantity |
| currency | string | Yes | Currency that the order quantity is specified in, can be either side of the symbol |
| orderType | ["MARKET", "LIMIT"] | Yes | Order type, MARKET or LIMIT |
| limitPrice | string | No | Limit price, required if order type is LIMIT |
| timeInForce | ["FOK", "GTC", "IOC"] | No | Time in force, FOK = Fill Or Kill, GTC = Good Till Cancel, IOC = Immediate Or Cancel |
Response
| Parameter | Type | Required | Description |
|---|---|---|---|
| messageType | string | Yes | ExecutionReport |
| timestamp | string (date-time) | Yes | RFC3990 date-time string |
| clOrderId | string | Yes | Client order ID as specified on the order request |
| orderId | string | Yes | Anchorage order ID |
| accountId | string | Yes | Anchorage brokerage account ID as specified on the order request |
| symbol | string | Yes | Trading symbol as specified on the order request, e.g. "BTC-USD" |
| side | ["BUY", "SELL"] | Yes | Order side, BUY or SELL, as specified on the order request |
| orderQty | string | Yes | Order quantity as specified on the order request |
| currency | string | Yes | Currency that the order quantity is specified in, as specified on the order request |
| orderType | ["MARKET", "LIMIT"] | Yes | Order type, MARKET or LIMIT, as specified on the order request |
| limitPrice | string | No | Limit price as specified on the order request |
| timeInForce | ["FOK", "GTC", "IOC"] | No | Time in force as specified on the order request |
| orderStatus | ["PENDING", "NEW", "REJECTED", "PENDING_CANCEL", "CANCELED", "FILLED", "PARTIALLY_FILLED"]["PENDING", "NEW", "REJECTED", "PENDING_CANCEL", "CANCELED", "FILLED", "PARTIALLY_FILLED"] | Yes | Order status |
| execId | string | No | Execution ID that can be used later to query for trades. |
| execType | ["NEW", "FILL", "CANCEL", "REJECT", "CANCEL_REJECT"]["NEW", "FILL", "CANCEL", "REJECT", "CANCEL_REJECT"] | No | Type of the execution |
| avgPx | string | No | Average price of filled portion of the order |
| avgPxAllIn | string | No | Average price including fees of filled portion of the order |
| cumQty | string | Yes | Cumulative quantity filled for the order |
| fillPx | string | No | Fill quantity of this execution (execType="FILL") |
| fillQty | string | No | Fill price of this execution (excluding fees) |
| leavesQty | string | Yes | Leaves quantity of this order |
| cancelQty | string | No | Canceled quantity of this order |
| fee | string | No | Anchorage commission charged for this execution |
| feeCurrency | string | No | Currency that the commission is charged in |
| rejectReason | string | No | Reason for rejection |
| rejectReasonText | string | No | Additional description for reason of reject |
| submitTime | string (date-time) | Yes | Order submission time, date-time in RFC3990 format |
| transactTime | string (date-time) | No | Transaction time, date-time in RFC3990 format |
CancelOrderRequest
Cancel an order, origClOrderId and accountId must matches the original order request. orderId must match the order id returned on the execution reports.
Cancel request on any completed order will be rejected.
Example cancel request:
{
"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:
{
"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 of cancel reject response:
{
"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 | Y | OrderCancelRequest |
| timestamp | string (date-time) | Y | RFC3990 date-time string |
| origClOrderId | string | Y | Client order ID as specified on the order request |
| orderId | string | Y | Anchorage order ID |
| accountId | string | Y | Anchorage brokerage account ID as specified on the order request |
Response
See response for "NewOrderSingle" request.
ExecutionReportResendRequest
Resend execution reports for an order. This request allows 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.
This request can be used to to synchronize order states after a websocket disconnect.
Example resend request:
{
"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 | Y | ExecutionReportResendRequest |
| timestamp | string (date-time) | Y | RFC3990 date-time string |
| origClOrderId | string | Y | Client order ID as specified on the order request |
| orderId | string | Y | Anchorage order ID |
| accountId | string | Y | Anchorage brokerage account ID as specified on the order request |
Response
A stream of execution reports. See response for "NewOrderSingle" request.
Updated 10 months ago