Modify GTT Order
Modify Single Leg GTT Order
- Curl
- Python
- Node.js
- Java
- PHP
curl --location --request PUT 'https://api.upstox.com/v3/order/gtt/modify' \
--header 'accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--header 'Content-Type: application/json' \
--data '{
"type": "SINGLE",
"quantity": 1,
"rules": [
{
"strategy": "ENTRY",
"trigger_type": "ABOVE",
"trigger_price": 7.3
}
],
"gtt_order_id": "GTT-C25270200137952"
}'
import requests
url = 'https://api.upstox.com/v3/order/gtt/modify'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
"type": "SINGLE",
"quantity": 1,
"rules": [
{
"strategy": "ENTRY",
"trigger_type": "ABOVE",
"trigger_price": 7.3
}
],
"gtt_order_id": "GTT-C25270200137952"
}
try:
# Send the PUT request
response = requests.put(url, json=data, headers=headers)
# Print the response status code and body
print('Response Code:', response.status_code)
print('Response Body:', response.json())
except Exception as e:
# Handle exceptions
print('Error:', str(e))
const axios = require('axios');
const url = 'https://api.upstox.com/v3/order/gtt/modify';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
type: 'SINGLE',
quantity: 1,
rules: [
{
strategy: 'ENTRY',
trigger_type: 'ABOVE',
trigger_price: 7.3
}
],
gtt_order_id: 'GTT-C25270200137952'
};
axios.put(url, data, { headers })
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v3/order/gtt/modify";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"type\": \"SINGLE\","
+ "\"quantity\": 1,"
+ "\"rules\": ["
+ "{"
+ "\"strategy\": \"ENTRY\","
+ "\"trigger_type\": \"ABOVE\","
+ "\"trigger_price\": 7.3"
+ "}"
+ "],"
+ "\"gtt_order_id\": \"GTT-C25270200137952\""
+ "}";
// Create the HttpClient
HttpClient httpClient = HttpClient.newHttpClient();
// Create the HttpRequest
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", token)
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
try {
// Send the request and retrieve the response
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
// Print the response status code and body
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v3/order/gtt/modify';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'type' => 'SINGLE',
'quantity' => 1,
'rules' => [
[
'strategy' => 'ENTRY',
'trigger_type' => 'ABOVE',
'trigger_price' => 7.3
]
],
'gtt_order_id' => 'GTT-C25270200137952'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if ($response === false) {
echo 'Error: ' . curl_error($ch);
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
?>
Modify Multiple Leg GTT Order
- Curl
- Python
- Node.js
- Java
- PHP
curl --location --request PUT 'https://api.upstox.com/v3/order/gtt/modify' \
--header 'accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--header 'Content-Type: application/json' \
--data '{
"type": "MULTIPLE",
"quantity": 1,
"rules": [
{
"strategy": "ENTRY",
"trigger_type": "ABOVE",
"trigger_price": 7.3
},
{
"strategy": "TARGET",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.64
},
{
"strategy": "STOPLOSS",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.1
}
],
"gtt_order_id": "GTT-C25280200137522"
}'
import requests
url = 'https://api.upstox.com/v3/order/gtt/modify'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
"type": "MULTIPLE",
"quantity": 1,
"rules": [
{
"strategy": "ENTRY",
"trigger_type": "ABOVE",
"trigger_price": 7.3
},
{
"strategy": "TARGET",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.64
},
{
"strategy": "STOPLOSS",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.1
}
],
"gtt_order_id": "GTT-C25280200137522"
}
try:
# Send the PUT request
response = requests.put(url, json=data, headers=headers)
# Print the response status code and body
print('Response Code:', response.status_code)
print('Response Body:', response.json())
except Exception as e:
# Handle exceptions
print('Error:', str(e))
const axios = require('axios');
const url = 'https://api.upstox.com/v3/order/gtt/modify';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
type: 'MULTIPLE',
quantity: 1,
rules: [
{
strategy: 'ENTRY',
trigger_type: 'ABOVE',
trigger_price: 7.3
},
{
strategy: 'TARGET',
trigger_type: 'IMMEDIATE',
trigger_price: 7.64
},
{
strategy: 'STOPLOSS',
trigger_type: 'IMMEDIATE',
trigger_price: 7.1
}
],
gtt_order_id: 'GTT-C25280200137522'
};
axios.put(url, data, { headers })
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v3/order/gtt/modify";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"type\": \"MULTIPLE\","
+ "\"quantity\": 1,"
+ "\"rules\": ["
+ "{"
+ "\"strategy\": \"ENTRY\","
+ "\"trigger_type\": \"ABOVE\","
+ "\"trigger_price\": 7.3"
+ "},"
+ "{"
+ "\"strategy\": \"TARGET\","
+ "\"trigger_type\": \"IMMEDIATE\","
+ "\"trigger_price\": 7.64"
+ "},"
+ "{"
+ "\"strategy\": \"STOPLOSS\","
+ "\"trigger_type\": \"IMMEDIATE\","
+ "\"trigger_price\": 7.1"
+ "}"
+ "],"
+ "\"gtt_order_id\": \"GTT-C25280200137522\""
+ "}";
// Create the HttpClient
HttpClient httpClient = HttpClient.newHttpClient();
// Create the HttpRequest
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", token)
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
try {
// Send the request and retrieve the response
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
// Print the response status code and body
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v3/order/gtt/modify';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'type' => 'MULTIPLE',
'quantity' => 1,
'rules' => [
[
'strategy' => 'ENTRY',
'trigger_type' => 'ABOVE',
'trigger_price' => 7.3
],
[
'strategy' => 'TARGET',
'trigger_type' => 'IMMEDIATE',
'trigger_price' => 7.64
],
[
'strategy' => 'STOPLOSS',
'trigger_type' => 'IMMEDIATE',
'trigger_price' => 7.1
]
],
'gtt_order_id' => 'GTT-C25280200137522'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if ($response === false) {
echo 'Error: ' . curl_error($ch);
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
?>