Modify Order Sandbox Enabled Deprecated
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.
Request
curl --location --request PUT 'https://api-hft.upstox.com/v2/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
}'
Additional samples in various languages are available in 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"
}
}
| 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 |
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
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location --request PUT 'https://api-hft.upstox.com/v2/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
}'
import requests
url = 'https://api-hft.upstox.com/v2/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/v2/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/v2/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/v2/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.OrderApi(upstox_client.ApiClient(configuration))
body = upstox_client.ModifyOrderRequest(2, "DAY", 0, "231222010275930", "MARKET", 0, 0)
api_version = '2.0' # str | API Version Header
try:
# Modify order
api_response = api_instance.modify_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->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.OrderApi();
let body = new UpstoxClient.ModifyOrderRequest(UpstoxClient.ModifyOrderRequest.ValidityEnum.DAY,0,"240111010331447",UpstoxClient.ModifyOrderRequest.OrderTypeEnum.MARKET,0);
let apiVersion = "2.0"; // String | API Version Header
apiInstance.modifyOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} 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.ModifyOrderRequest;
import com.upstox.api.ModifyOrderResponse;
import com.upstox.auth.*;
import io.swagger.client.api.OrderApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
OrderApi apiInstance = new OrderApi();
ModifyOrderRequest body = new ModifyOrderRequest();
body.setQuantity(2);
body.setValidity(ModifyOrderRequest.ValidityEnum.DAY);
body.setPrice(0F);
body.setDisclosedQuantity(0);
body.setTriggerPrice(0F);
body.setOrderType(ModifyOrderRequest.OrderTypeEnum.MARKET);
body.setOrderId("240125010587640");
String apiVersion = "2.0"; // String | API Version Header
try {
ModifyOrderResponse result = apiInstance.modifyOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Loading...