Modify Order V3 Sandbox Enabled
API to modify an open or pending order. To perform a modification, the orderId is a required field. Along with the orderId, you should include any optional parameters that require modification. If no optional parameters are included in the modification request, the default values will be assumed from the original order.
Additionally this API includes latency information in the meta data object of the response, providing insight into the time Upstox took to process your request.
Request
curl --location --request PUT 'https://api-hft.upstox.com/v3/order/modify' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 2,
"validity": "DAY",
"price": 16.8,
"order_id": "240108010918222",
"order_type": "LIMIT",
"disclosed_quantity": 0,
"trigger_price": 16.9
}'
For additional samples in various languages, please refer to the Sample code section on this page.
Request Body
| Name | Required | Type | Description |
|---|---|---|---|
| quantity | false | integer (int32) | Quantity with which the order was placed |
| validity | true | string | Order validity (DAY- Day and IOC- Immediate or Cancel (IOC) order). Possible values: DAY, IOC. |
| price | true | number (float) | Price at which the order was placed |
| order_id | true | string | The order ID for which the order must be modified. For the regex pattern applicable to this field, see the Field Pattern Appendix. |
| order_type | true | string | Type of order. It can be one of the following MARKET refers to market order LIMILT refers to Limit Order SL refers to Stop Loss Limit SL-M refers to Stop Loss Market. Possible values: MARKET, LIMIT, SL, SL-M. |
| disclosed_quantity | false | integer (int32) | Indicates the volume to be displayed in the market depth. If provided, this value must be non-zero. |
| trigger_price | true | number (float) | If the order is a stop loss order then the trigger price to be set is mentioned here |
Responses
- 200
- 4XX
Response Body
{
"status": "success",
"data": {
"order_id": "1644490272000"
},
"metadata": {
"latency": 40
}
}
| Name | Type | Description |
|---|---|---|
| status | string | A string indicating the outcome of the request. Typically success for successful operations. |
| data | object | Response data for modify order request |
| data.order_id | string | Order ID |
| metadata | object | Order metadata associated with successful order modified. |
| metadata.latency | integer | The overall time taken by API platform to process the order modification request, measured in milliseconds. |
Error codes
| Error code | Description |
|---|---|
| UDAPI1004 | Valid order type is required - Please ensure you provide an acceptable type for the order. |
| UDAPI1007 | Validity is required - You need to specify the duration or validity for the order. |
| UDAPI1056 | The 'order_type' is invalid - The order type you've provided isn't recognized or accepted. |
| UDAPI1055 | The 'validity' is invalid - The provided validity doesn't match any of the recognized types. |
| UDAPI1008 | Price is required - Please specify the desired price for your order. |
| UDAPI1036 | The 'trigger_price' is required - A trigger price must be specified for this type of order. |
| UDAPI1030 | 'price' is not required - For this order type, you don't need to specify a price. |
| UDAPI1029 | 'price' is required - A valid price must be provided for this type of order. |
| UDAPI1031 | Price and Trigger price both are required - Both price values, regular and trigger, need to be provided for this order. |
| UDAPI1032 | Only 'trigger_price' is required - For this type of order, only a trigger price value needs to be specified. |
| UDAPI100049 | Access to this API has been restricted for your account. Please use 'Uplink Business' to place/modify/cancel the order. - Use 'Uplink Business' for order operations. |
| UDAPI100010 | Order not found - The system couldn't locate the order you're referring to. |
| UDAPI100041 | Modifications of already cancelled/rejected/completed orders is not allowed - You cannot make changes to orders that are already finalized in some manner. |
| UDAPI1039 | Disclosed quantity should not be less than 10% of the quantity - The revealed amount in your order should be at least 10% of the total order amount. |
| UDAPI1003 | Order id is required - Thrown when order number is not provided. |
Sample Code
Modify a delivery order
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
import requests
url = 'https://api-hft.upstox.com/v3/order/modify'
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
data = {
'quantity': 3,
'validity': 'DAY',
'price': 16.8,
'order_id': '240108010918222',
'order_type': 'LIMIT',
'disclosed_quantity': 0,
'trigger_price': 16.9
}
response = requests.put(url, headers=headers, json=data)
print(response.text)
const axios = require('axios');
const url = 'https://api-hft.upstox.com/v3/order/modify';
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
const data = {
'quantity': 2,
'validity': 'DAY',
'price': 16.8,
'order_id': '240108010918222',
'order_type': 'LIMIT',
'disclosed_quantity': 0,
'trigger_price': 16.9
};
axios.put(url, data, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error.response.data));
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://api-hft.upstox.com/v3/order/modify");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("PUT");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer {your_access_token}");
connection.setDoOutput(true);
String data = "{\"quantity\": 2, \"validity\": \"DAY\", \"price\": 16.8, \"order_id\": \"240108010918222\", \"order_type\": \"LIMIT\", \"disclosed_quantity\": 0, \"trigger_price\": 16.9}";
try (OutputStream os = connection.getOutputStream()) {
byte[] input = data.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$url = 'https://api-hft.upstox.com/v3/order/modify';
$headers = array(
'Accept: application/json',
'Content-Type: application/json',
'Authorization: Bearer {your_access_token}'
);
$data = array(
'quantity' => 2,
'validity' => 'DAY',
'price' => 16.8,
'order_id' => '240108010918222',
'order_type' => 'LIMIT',
'disclosed_quantity' => 0,
'trigger_price' => 16.9
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
}
curl_close($ch);
echo $result;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
body = upstox_client.ModifyOrderRequest(1, "DAY", 9.12, "25030310405859", "LIMIT", 0, 0)
try:
api_response = api_instance.modify_order(body)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApiV3->modify_order: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OrderApiV3();
body = new UpstoxClient.ModifyOrderRequest(UpstoxClient.ModifyOrderRequest.ValidityEnum.DAY,0,"2505010177418",UpstoxClient.ModifyOrderRequest.OrderTypeEnum.MARKET,1);
body.quantity = 1;
apiInstance.modifyOrder(body, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.OrderApiV3;
import com.upstox.api.ModifyOrderRequest;
import com.upstox.api.ModifyOrderV3Response;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setAccessToken("{your_access_token}");
OrderApiV3 apiInstance = new OrderApiV3();
ModifyOrderRequest modifyOrderRequest1 = new ModifyOrderRequest();
modifyOrderRequest1.setQuantity(2);
modifyOrderRequest1.setValidity(ModifyOrderRequest.ValidityEnum.DAY);
modifyOrderRequest1.setPrice(9F);
modifyOrderRequest1.setDisclosedQuantity(0);
modifyOrderRequest1.setTriggerPrice(0F);
modifyOrderRequest1.setOrderType(ModifyOrderRequest.OrderTypeEnum.LIMIT);
modifyOrderRequest1.setOrderId("250128010532402");
try {
ModifyOrderV3Response result = apiInstance.modifyOrder(modifyOrderRequest1);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApiV3->modifyOrder: " + e.getMessage());
}
}
}
Loading...