Place Order V3
Place an order with slicing enabled
- Curl
- Python
- Node.js
- Java
- PHP
curl --location 'https://api-hft.upstox.com/v3/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 4000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|43919",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": true
}'
import requests
url = 'https://api-hft.upstox.com/v3/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 4000,
'product': 'D',
'validity': 'DAY',
'price': 0,
'tag': 'string',
'instrument_token': 'NSE_FO|43919',
'order_type': 'MARKET',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 0,
'is_amo': False,
'slice': True
}
try:
# Send the POST request
response = requests.post(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-hft.upstox.com/v3/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 4000,
product: 'D',
validity: 'DAY',
price: 0,
tag: 'string',
instrument_token: 'NSE_FO|43919',
order_type: 'MARKET',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 0,
is_amo: false,
slice: true
};
axios.post(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-hft.upstox.com/v3/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 4000,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|43919\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": false,"
+ "\"slice\": true"
+ "}";
// 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)
.POST(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-hft.upstox.com/v3/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 4000,
'product' => 'D',
'validity' => 'DAY',
'price' => 0,
'tag' => 'string',
'instrument_token' => 'NSE_FO|43919',
'order_type' => 'MARKET',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 0,
'is_amo' => false,
'slice' => true,
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
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);
?>
Place an order with slicing disabled
- Curl
- Python
- Node.js
- Java
- PHP
curl --location 'https://api-hft.upstox.com/v3/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|43919",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
}'
import requests
url = 'https://api-hft.upstox.com/v3/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 25,
'product': 'D',
'validity': 'DAY',
'price': 0,
'tag': 'string',
'instrument_token': 'NSE_FO|43919',
'order_type': 'MARKET',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 0,
'is_amo': False,
'slice': False
}
try:
# Send the POST request
response = requests.post(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-hft.upstox.com/v3/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 25,
product: 'D',
validity: 'DAY',
price: 0,
tag: 'string',
instrument_token: 'NSE_FO|43919',
order_type: 'MARKET',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 0,
is_amo: false,
slice: false
};
axios.post(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-hft.upstox.com/v3/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 25,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|43919\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": false,"
+ "\"slice\": false"
+ "}";
// 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)
.POST(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-hft.upstox.com/v3/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 25,
'product' => 'D',
'validity' => 'DAY',
'price' => 0,
'tag' => 'string',
'instrument_token' => 'NSE_FO|43919',
'order_type' => 'MARKET',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 0,
'is_amo' => false,
'slice' => false,
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
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);
?>