PUT Modify Order

PUT https://api.swaycharts.io/dxsca-web/accounts/{account code}/orders

Modifies an existing order on an account

This API allows editing order details on an account. Users can always edit orders on their own accounts, but can only edit orders on behalf of other accounts if a special permission is set. Only conditional requests are accepted.

// Request

A Single Order Request or a Order Group Request that has some fields changed. User must submit the whole order request to ensure idempotency of the protocol. Some of the fields cannot be changed after an order is issued; attempt to do so will result in the 409 Conflict error.

The API supports modifications of an order group with a single order or a single order with an order group.

It is impossible to add and remove orders to/from a group in a single request. It's necessary to first remove an order from a group and then add a new one with a separate request.

Authorization header should be included in case of basic authentication
// Path Parameters

accountCode - unique code assigned to an account (URL-encoded, https://en.wikipedia.org/wiki/Percent-encoding). See account code
// Response

Updated Order Response or a list of Order Responses for all orders in a group (if a group was submitted)

The ETag header is sent in response. See conditional updates
// Errors

Common errors

API is not permitted for the user or account with the given id doesn't exist or account with the given id is not accessible for the user or an order with such an id is not found

Status code: 404 Not Found
Error code: 2
Description: Entity not found at server
Order request or order group is not well-formed or is semantically incorrect (e.g. limit order doesn't have price or order group includes both OCO and Contingent fields)

Status code: 400 Bad Request
Error code: 33
Description: Incorrect request (<details about an error>)
An attempt is made to edit parameters that cannot be edited (such as order id or order type)

Status code: 409 Conflict
Error code: <various>
Description: <various>
Order didn't pass validation

Status code: 409 Conflict
Error code: <various>
Description: <various>
User didn't submit the conditional request header (If-Match)

Status code: 403 Forbidden
Error code: 99
Description: Conditional request required
Conditional request header (If-Match) doesn't match current order state

Status code: 412 Precondition Failed
Error code: N/A
Description: N/A

Modification of an order group to a single order

It is impossible to add and remove orders to/from a group in a single request. It's necessary to first remove an order from a group and then add a new one with a separate request.

// 1. Create the IF-THEN order group JSON

{
    "orders": [
        {
            "orderCode": "80t1",
            "type": "LIMIT",
            "instrument": "EUR/USD",
            "quantity": "300000",
            "positionEffect": "OPEN",
            "side": "BUY",
            "limitPrice": "0.05",
            "tif": "GTC"
        },
        {
            "orderCode": "80t2",
            "type": "STOP",
            "instrument": "EUR/USD",
            "quantity": "0",
            "positionEffect": "CLOSE",
            "side": "SELL",
            "stopPrice": "0.7",
            "tif": "GTC"
        },
        {
            "orderCode": "80t3",
            "type": "LIMIT",
            "instrument": "EUR/USD",
            "quantity": "0",
            "positionEffect": "CLOSE",
            "side": "SELL",
            "limitPrice": "1.3",
            "tif": "GTC"
        }
    ],
    "contingencyType": "IF-THEN"
}
// 2. Response

{
    "orderResponses": [
        {
            "orderId": 46072658,
            "updateOrderId": 46072658
        },
        {
            "orderId": 46072659,
            "updateOrderId": 46072659
        },
        {
            "orderId": 46072660,
            "updateOrderId": 46072660
        }
    ]
}
// 3. Observe the created order group with the List Open Orders request

{
     "account": "default:ssp1",
     "version": 447,
     "orderId": 46072658,
     "orderCode": "dxsca-integration-session-code:80t1",
     "clientOrderId": "80t1",
     "actionCode": "dxsca-integration-session-code:80t1",
     "legCount": 1,
     "type": "LIMIT",
     "instrument": "EUR/USD",
     "status": "WORKING",
     "finalStatus": false,
     "legs": [
         {
             "instrument": "EUR/USD",
             "positionEffect": "OPEN",
             "positionCode": "46072658",
             "price": 0.05,
             "legRatio": 1,
             "quantity": 300000,
             "filledQuantity": 0,
             "remainingQuantity": 300000
         }
     ],
     "side": "BUY",
     "tif": "GTC",
     "issueTime": "2017-08-28T14:19:31.731Z",
     "transactionTime": "2017-08-28T14:19:31.731Z",
     "links": [
         {
             "linkType": "CHILD",
             "linkedOrder": "dxsca-integration-session-code:80t2",
             "linkedClientOrderId": "80t2"
         },
         {
             "linkType": "CHILD",
             "linkedOrder": "dxsca-integration-session-code:80t3",
             "linkedClientOrderId": "80t3"
         }
     ],
     "executions": [
         {
             "account": "default:ssp1",
             "executionCode": "816051:16502",
             "orderCode": "dxsca-integration-session-code:80t1",
             "updateOrderId": 46072658,
             "version": 447,
             "clientOrderId": "80t1",
             "actionCode": "dxsca-integration-session-code:80t1",
             "status": "WORKING",
             "finalStatus": false,
             "filledQuantity": 0,
             "transactionTime": "2017-08-28T14:19:31.731Z"
         }
     ],
     "cashTransactions": []
 },
 {
     "account": "default:ssp1",
     "version": 448,
     "orderId": 46072659,
     "orderCode": "dxsca-integration-session-code:80t2",
     "clientOrderId": "80t2",
     "actionCode": "dxsca-integration-session-code:80t2",
     "legCount": 1,
     "type": "STOP",
     "instrument": "EUR/USD",
     "status": "WORKING",
     "finalStatus": false,
     "legs": [
         {
             "instrument": "EUR/USD",
             "positionEffect": "CLOSE",
             "positionCode": "46072658",
             "price": 0.7,
             "legRatio": 1,
             "filledQuantity": 0
         }
     ],
     "side": "SELL",
     "tif": "GTC",
     "issueTime": "2017-08-28T14:19:31.731Z",
     "transactionTime": "2017-08-28T14:19:31.731Z",
     "links": [
         {
             "linkType": "PARENT",
             "linkedOrder": "dxsca-integration-session-code:80t1",
             "linkedClientOrderId": "80t1"
         }
     ],
     "executions": [
         {
             "account": "default:ssp1",
             "executionCode": "816051:16503",
             "orderCode": "dxsca-integration-session-code:80t2",
             "updateOrderId": 46072659,
             "version": 448,
             "clientOrderId": "80t2",
             "actionCode": "dxsca-integration-session-code:80t2",
             "status": "WORKING",
             "finalStatus": false,
             "filledQuantity": 0,
             "transactionTime": "2017-08-28T14:19:31.731Z"
         }
     ],
     "cashTransactions": []
 },
 {
     "account": "default:ssp1",
     "version": 449,
     "orderId": 46072660,
     "orderCode": "dxsca-integration-session-code:80t3",
     "clientOrderId": "80t3",
     "actionCode": "dxsca-integration-session-code:80t3",
     "legCount": 1,
     "type": "LIMIT",
     "instrument": "EUR/USD",
     "status": "WORKING",
     "finalStatus": false,
     "legs": [
         {
             "instrument": "EUR/USD",
             "positionEffect": "CLOSE",
             "positionCode": "46072658",
             "price": 1.3,
             "legRatio": 1,
             "filledQuantity": 0
         }
     ],
     "side": "SELL",
     "tif": "GTC",
     "issueTime": "2017-08-28T14:19:31.731Z",
     "transactionTime": "2017-08-28T14:19:31.731Z",
     "links": [
         {
             "linkType": "PARENT",
             "linkedOrder": "dxsca-integration-session-code:80t1",
             "linkedClientOrderId": "80t1"
         }
     ],
     "executions": [
         {
             "account": "default:ssp1",
             "executionCode": "816051:16504",
             "orderCode": "dxsca-integration-session-code:80t3",
             "updateOrderId": 46072660,
             "version": 449,
             "clientOrderId": "80t3",
             "actionCode": "dxsca-integration-session-code:80t3",
             "status": "WORKING",
             "finalStatus": false,
             "filledQuantity": 0,
             "transactionTime": "2017-08-28T14:19:31.731Z"
         }
     ],
     "cashTransactions": []
 }
// 4. Create a modify single order request to change the quantity and limitPrice fields

{
       "orderCode":"80t1",
       "instrument":"EUR/USD",
       "quantity":"200000",
       "positionEffect":"OPEN",
       "side":"BUY",
       "limitPrice":"0.04",
       "tif":"GTC"
 }
// 5. Response

{
     "orderId": 46072658,
     "updateOrderId": 46073016
 }
// 6. Observe created orders and see that the changes have been applied

{
     "account": "default:ssp1",
     "version": 452,
     "orderId": 46072658,
     "orderCode": "dxsca-integration-session-code:80t1",
     "clientOrderId": "80t1",
     "actionCode": "816099:2",
     "legCount": 1,
     "type": "LIMIT",
     "instrument": "EUR/USD",
     "status": "WORKING",
     "finalStatus": false,
     "legs": [
         {
             "instrument": "EUR/USD",
             "positionEffect": "OPEN",
             "positionCode": "46072658",
             "price": 0.04,
             "legRatio": 1,
             "quantity": 200000,
             "filledQuantity": 0,
             "remainingQuantity": 200000
         }
     ],
     "side": "BUY",
     "tif": "GTC",
     "issueTime": "2017-08-28T14:19:31.731Z",
     "transactionTime": "2017-08-28T14:38:18.420Z",
     "executions": [
         {
             "account": "default:ssp1",
             "executionCode": "816051:16502",
             "orderCode": "dxsca-integration-session-code:80t1",
             "updateOrderId": 46072658,
             "version": 447,
             "clientOrderId": "80t1",
             "actionCode": "816099:2",
             "status": "WORKING",
             "finalStatus": false,
             "filledQuantity": 0,
             "transactionTime": "2017-08-28T14:19:31.731Z"
         },
         {
             "account": "default:ssp1",
             "executionCode": "816051:16755",
             "orderCode": "dxsca-integration-session-code:80t1",
             "updateOrderId": 46073016,
             "version": 451,
             "clientOrderId": "80t1",
             "actionCode": "816099:2",
             "status": "WORKING",
             "finalStatus": false,
             "filledQuantity": 0,
             "transactionTime": "2017-08-28T14:38:18.420Z"
         },
         {
             "account": "default:ssp1",
             "executionCode": "816051:16756",
             "orderCode": "dxsca-integration-session-code:80t1",
             "updateOrderId": 46072658,
             "version": 452,
             "clientOrderId": "80t1",
             "actionCode": "816099:2",
             "status": "WORKING",
             "finalStatus": true,
             "filledQuantity": 0,
             "transactionTime": "2017-08-28T14:38:18.420Z"
         }
     ],
     "cashTransactions": []
 }

Last updated