Modify an Order
API Description
This interface allows users to modify an unfilled order. Please note that some parameters, such as margin and leverage, cannot be modified using this interface.
Note: Modify an Order is only available via RESTful API.
Precautions
-
If an error occurs while modifying certain parameters (e.g., insufficient quantity to buy contract, leverage adjustment, modifying margin), the order will be cancelled.
-
This interface does not support modifying margin mode. If an attempt is made, the following error will be returned, and the order will get cancelled. To modify the margin mode, please use the dedicated interface in Futures > Account & Assets > Set the Position margin Mode.
'code': 9050, 'msg': 'The margin mode cannot be changed for existing orders'
- If an existing order has a specified leverage for an instrument, modifying the leverage for subsequent orders on the same instrument is not allowed. If an attempt is made, the following error will be returned, and the order will be cancelled.
'code': 9081, 'msg': 'New opening cannot adjust leverage multiples'
- If the request parameter positionType is set to planTrigger, the response parameter openId will be null, but the order will still be successfully placed and can be viewed on the webpage under "Open Orders". For interface to view open orders, go to Futures > Check Orders > Get Current Orders.
'code':0, 'data': {'value': 'null'}, 'msg': ''
- During the funding period, operations related to transaction such as placing orders or closing positions are not permitted. Attempting these actions will result in an error response. The funding process typically takes 30 to 40 seconds. It is recommended to wait at least 1 minute before retrying transaction related operations. For the exact funding fee schedule, please refer to the official webpage.
- CoinW allows traders to open both long and short positions on the same asset simultaneously, enabling hedging functionality and supporting the development of more flexible and sophisticated trading strategies.
Authentication
This is a private interface and requires authentication. For details on using the RESTful API, refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
Request Method
PUT
Endpoint
Frequency Limit
The frequency limit for this interface is 10 requests/s per user ID and IP. In addition to this per-interface limit, a global rate limit is also enforced.
For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| id | true | Long | Order ID of the order to be modified |
| instrument | true | String | The base currency of the instrument. (e.g., BTC or btc). This parameter is case-insensitive. Note: For instruments that start with numbers (e.g., 1000PEPE), both uppercase and lowercase formats are valid. |
| direction | true | String | Trade direction: long, short. Note: To modify the direction, provide the new direction; otherwise, keep it unchanged. |
| leverage | true | Integer | Position leverage |
| quantityUnit | true | Integer | Specifies the unit for order size: 0: Denominated in the quote currency (e.g., USDT in BTC-USDT), 1: Denominated in number of contracts, 2: Denominated in the base currency (e.g., BTC in BTC-USDT) Note 1: If the base currency is insufficient for at least one contract, modifying this parameter will result in an error, and the order will be canceled. Note 2: To modify the unit for order size, provide a new quantityUnit; otherwise, keep it unchanged. |
| quantity | true | Intger/String | Specifies order size based on quantityUnit: If quantityUnit=0, the quantity is measured the quote currency (e.g., USDT in BTC-USDT), If quantityUnit=1, the quantity is measured in number of contracts, If quantityUnit=2, the quantity is measured in the base currency (e.g., BTC in BTC-USDT) Note: If the base currency is insufficient for at least one contract, modifying this parameter will result in an error, and the order will be canceled. |
| positionModel | true | Integer | Position margin mode: 0: Isolated margin 1: Cross margin Note: The margin mode cannot be changed for existing orders. If an attempt is made, the order will be cancelled. Tip: Modify the margin mode before placing the order. |
| positionType | true | String | Order type: execute: Market order plan: for plan different orders including limit order, triggered limit order, limit order with SL/TP, triggered limit order with SL/TP, triggered market orders, triggered market orders with SL/TP planTrigger: planned trigger order Note: For trailing SL/TP, submit a market/limit order first, then use a dedicated interface to set up trailing SL/TP. |
| openPrice | false | BigDecimal | The specified order price. Note: If the base currency is insufficient for at least one contract, modifying this parameter will result in an error, and the order will be canceled. |
| stopLossPrice | false | BigDecimal | Stop loss price |
| stopProfitPrice | false | BigDecimal | Take profit price |
| triggerPrice | false | BigDecimal | Trigger price for a perpetual contract plan order. |
| triggerType | false | integer | Specifies order type once triggerPrice is met: 0: Limit order 1: Market order Note: The order can be changed from limit to market. |
| goldId | false | Integer | User experience golden ID |
| feeType | false | Integer | Fee type: 1: maker fee 0: taker fee |
| orderPrice | false | Integer | Commission price |
| orderBookId | false | Long | Order ID |
| useAlmightyGold | false | boolean | Whether to use Mega Coupon |
| thirdOrderId | false | String | A custom order ID assigned by the user to uniquely distinguish different positions. Note: (1) Maximum length: 50 characters; only Latin letters, numbers, hyphens ( -), and underscores (_) are permitted. (2) This parameter is mandatory for batch order closing. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| originId | Long | Original order ID |
| editId | Long | Modified order ID |
Request Example
The following Python code shows how to modify an order.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
params = {
"id": "33308754803838259",
"instrument": "btc",
"direction": "long",
"leverage": 1,
"quantityUnit": 1,
"quantity": "1",
"positionModel": 0,
"positionType": "plan",
"openPrice" : 92000,
"stopProfitPrice" : 94000,
"stopLossPrice" : 90500,
"triggerPrice" : "90800",
"triggerType" : 1,
}
api_url = "/v1/perpum/order"
method = "PUT"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # function FuturesRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
Response Example
The following is an example response returned by the above Python request:
{'code': 0, 'data': {'editId': 33308754804673617, 'originId': 33308754803838259}, 'msg': ''}