Modify Order
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();
}
}
}