exchange.ModifyConditionOrder
The exchange.ModifyConditionOrder() function is used to modify an existing conditional order, allowing modification of the order quantity, trigger conditions, and execution price. It supports modifying other attributes of the conditional order through additional parameters (depending on exchange API support).
exchange.ModifyConditionOrder(orderId, side, amount, condition)Examples
-
Modify the quantity and trigger conditions of a conditional order.
javascriptfunction main() { // Create a take-profit conditional order var condition = { ConditionType: ORDER_CONDITION_TYPE_TP, TpTriggerPrice: 77, TpOrderPrice: 76 } var id = exchange.CreateConditionOrder("SOL_USDT.swap", "buy", 1, condition) Log("Original Condition Order ID:", id) Sleep(2000) // Query original conditional order info var order = exchange.GetConditionOrder(id) Log("Original Condition Order Info:", order) Sleep(1000) // Modify the quantity and trigger conditions of the conditional order var newCondition = { ConditionType: ORDER_CONDITION_TYPE_TP, TpTriggerPrice: 75, TpOrderPrice: 71 } var newId = exchange.ModifyConditionOrder(id, "buy", 2, newCondition) Log("Modified Condition Order ID:", newId) Sleep(2000) // Query modified conditional order info var newOrder = exchange.GetConditionOrder(newId) Log("Modified Condition Order Info:", newOrder) // Cancel the conditional order exchange.CancelConditionOrder(newId) }pythondef main(): # Create a take-profit conditional order condition = { "ConditionType": ORDER_CONDITION_TYPE_TP, "TpTriggerPrice": 77, "TpOrderPrice": 76 } id = exchange.CreateConditionOrder("SOL_USDT.swap", "buy", 1, condition) Log("Original Condition Order ID:", id) Sleep(2000) # Query original conditional order info order = exchange.GetConditionOrder(id) Log("Original Condition Order Info:", order) Sleep(1000) # Modify the quantity and trigger conditions of the conditional order newCondition = { "ConditionType": ORDER_CONDITION_TYPE_TP, "TpTriggerPrice": 75, "TpOrderPrice": 71 } newId = exchange.ModifyConditionOrder(id, "buy", 2, newCondition) Log("Modified Condition Order ID:", newId) Sleep(2000) # Query modified conditional order info newOrder = exchange.GetConditionOrder(newId) Log("Modified Condition Order Info:", newOrder) # Cancel the conditional order exchange.CancelConditionOrder(newId)c++void main() { // Create a take-profit conditional order OrderCondition condition = {.ConditionType = ORDER_CONDITION_TYPE_TP, .TpTriggerPrice = 77, .TpOrderPrice = 76}; auto id = exchange.CreateConditionOrder("SOL_USDT.swap", "buy", 1, condition); Log("Original Condition Order ID:", id); Sleep(2000); // Query original conditional order info auto order = exchange.GetConditionOrder(id); Log("Original Condition Order Info:", order); Sleep(1000); // Modify the quantity and trigger conditions of the conditional order OrderCondition newCondition = {.ConditionType = ORDER_CONDITION_TYPE_TP, .TpTriggerPrice = 75, .TpOrderPrice = 71}; auto newId = exchange.ModifyConditionOrder(id, "buy", 2, newCondition); Log("Modified Condition Order ID:", newId); Sleep(2000); // Query modified conditional order info auto newOrder = exchange.GetConditionOrder(newId); Log("Modified Condition Order Info:", newOrder); // Cancel the conditional order exchange.CancelConditionOrder(newId); } -
Use additional parameters (option) to modify the trigger price type of a conditional order.
javascriptfunction main() { // Create a take-profit conditional order var condition = { ConditionType: ORDER_CONDITION_TYPE_TP, TpTriggerPrice: 77, TpOrderPrice: 76 } var id = exchange.CreateConditionOrder("SOL_USDT.swap", "buy", 1, condition) Log("Original Condition Order ID:", id) Sleep(2000) // Modify the conditional order and set the trigger price type to index price // Pass additional parameters (JSON format) through the side parameter var option = {"newTpTriggerPxType": "index"} var sideWithOption = "buy;" + JSON.stringify(option) var newCondition = { ConditionType: ORDER_CONDITION_TYPE_TP, TpTriggerPrice: 75, TpOrderPrice: 71 } var newId = exchange.ModifyConditionOrder(id, sideWithOption, 2, newCondition) Log("Modified Condition Order ID:", newId) Sleep(2000) // Query the modified conditional order information var newOrder = exchange.GetConditionOrder(newId) Log("Modified Condition Order Info:", newOrder) // Cancel the conditional order exchange.CancelConditionOrder(newId) }pythonimport json def main(): # Create a take-profit conditional order condition = { "ConditionType": ORDER_CONDITION_TYPE_TP, "TpTriggerPrice": 77, "TpOrderPrice": 76 } id = exchange.CreateConditionOrder("SOL_USDT.swap", "buy", 1, condition) Log("Original Condition Order ID:", id) Sleep(2000) # Modify the conditional order and set the trigger price type to index price # Pass additional parameters (JSON format) through the side parameter option = {"newTpTriggerPxType": "index"} sideWithOption = "buy;" + json.dumps(option) newCondition = { "ConditionType": ORDER_CONDITION_TYPE_TP, "TpTriggerPrice": 75, "TpOrderPrice": 71 } newId = exchange.ModifyConditionOrder(id, sideWithOption, 2, newCondition) Log("Modified Condition Order ID:", newId) Sleep(2000) # Query the modified conditional order information newOrder = exchange.GetConditionOrder(newId) Log("Modified Condition Order Info:", newOrder) # Cancel the conditional order exchange.CancelConditionOrder(newId)c++void main() { // Create a take-profit conditional order OrderCondition condition = {.ConditionType = ORDER_CONDITION_TYPE_TP, .TpTriggerPrice = 77, .TpOrderPrice = 76}; auto id = exchange.CreateConditionOrder("SOL_USDT.swap", "buy", 1, condition); Log("Original Condition Order ID:", id); Sleep(2000); // Modify the conditional order and set the trigger price type to index price // Pass additional parameters (JSON format) through the side parameter json option = R"({"newTpTriggerPxType": "index"})"_json; string sideWithOption = "buy;" + option.dump(); OrderCondition newCondition = {.ConditionType = ORDER_CONDITION_TYPE_TP, .TpTriggerPrice = 75, .TpOrderPrice = 71}; auto newId = exchange.ModifyConditionOrder(id, sideWithOption, 2, newCondition); Log("Modified Condition Order ID:", newId); Sleep(2000); // Query the modified conditional order information auto newOrder = exchange.GetConditionOrder(newId); Log("Modified Condition Order Info:", newOrder); // Cancel the conditional order exchange.CancelConditionOrder(newId); }
Returns
| Type | Description |
string / null value | Returns the conditional order ID when modification is successful, returns null value when modification fails. The returned conditional order ID may be the same as or different from the original conditional order ID, depending on the exchange API implementation. Some exchanges return a new conditional order ID after modifying a conditional order, while others keep the conditional order ID unchanged. |
Arguments
| Name | Type | Required | Description |
orderId | string | Yes | The parameter |
side | string | Yes | The parameter For spot exchange objects, the optional values for the For futures exchange objects, the optional values for the Supports additional parameters (option): Additional parameters can be passed through the For example: Additional parameters are used to modify other attributes of the conditional order (such as trigger price type, etc.), and the specific supported parameters depend on the exchange API. |
amount | number | Yes | The parameter |
condition | object | Yes | The parameter
|
See Also
Condition exchange.CreateConditionOrder exchange.CancelConditionOrder exchange.GetConditionOrder exchange.GetConditionOrders
Remarks
The conditional order ID returned by the exchange.ModifyConditionOrder() function may behave differently depending on the exchange API implementation. Some exchange APIs return an updated conditional order ID, while others keep it unchanged. It is recommended to use the returned new conditional order ID for subsequent operations.
The exchange.ModifyConditionOrder() function does not validate parameter validity according to exchange interface rules, but submits parameters directly to the exchange API. When invalid parameters are passed (such as quantity of -1), the parameters may be ignored by the exchange, and the conditional order retains its original attributes.
Supports passing additional parameters (option) through the side parameter to modify other attributes of the conditional order. Additional parameters need to be merged with the side parameter in the format "side;{JSON object}" (recommended) or "side;key=value" (URL encoded format). For example, to modify the trigger price type: "buy;{\"newTpTriggerPxType\":\"index\"}".
For market order modification of conditional orders, you need to check whether the exchange API supports it. Setting TpOrderPrice or SlOrderPrice to -1 in the condition parameter indicates a market order.
When modifying a conditional order, other attributes of the conditional order (such as condition type, position mode, account mode, leverage, etc.) usually retain the original conditional order settings. If you need to modify these attributes, you can pass them through additional parameters (option), provided that the exchange API supports it.
You can modify the trigger price type through additional parameters, for example, changing the trigger price type from last price (last) to index price (index) or mark price (mark). The specific parameter names and support depend on the exchange API documentation.
Support for the modify conditional order function depends on the specific exchange. Some exchanges may not support the modify conditional order function or may only support modification of certain parameters. Please refer to the corresponding exchange's API documentation before use.