Place Multi Order
Place a multi order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/order/multi/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '[
{
"correlation_id": "1",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
},
{
"correlation_id": "2",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
}
]'
'
import requests
url = 'https://api.upstox.com/v2/order/multi/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = [
{
"correlation_id": "1",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": False,
"slice": False
},
{
"correlation_id": "2",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"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.upstox.com/v2/order/multi/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = [
{
"correlation_id": "1",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
},
{
"correlation_id": "2",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"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 Code:', response.status);
console.log('Response Body:', 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/v2/order/multi/place";
String token = "Bearer {your_access_token}";
// Set up the request body with multiple orders
String requestBody = "["
+ "{"
+ "\"correlation_id\": \"1\","
+ "\"quantity\": 25,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|62864\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": false,"
+ "\"slice\": false"
+ "},"
+ "{"
+ "\"correlation_id\": \"2\","
+ "\"quantity\": 25,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|62867\","
+ "\"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.upstox.com/v2/order/multi/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
// Set up the request body with multiple orders
$data = [
[
"correlation_id" => "1",
"quantity" => 25,
"product" => "D",
"validity" => "DAY",
"price" => 0,
"tag" => "string",
"instrument_token" => "NSE_FO|62864",
"order_type" => "MARKET",
"transaction_type" => "BUY",
"disclosed_quantity" => 0,
"trigger_price" => 0,
"is_amo" => false,
"slice" => false
],
[
"correlation_id" => "2",
"quantity" => 25,
"product" => "D",
"validity" => "DAY",
"price" => 0,
"tag" => "string",
"instrument_token" => "NSE_FO|62867",
"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);
?>
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.MultiOrderRequest(25, "D", "DAY", 0, "string", False, "NSE_FO|44166", "MARKET", "BUY",
0, 0, True, "1")
]
try:
api_response = api_instance.place_multi_order(body)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_order: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
apiInstance = new UpstoxClient.OrderApi();
body = []
order = new UpstoxClient.MultiOrderRequest(25,"D","DAY",0,false,"NSE_FO|44166","MARKET","BUY",0,0,true,"1");
order.tag = "string"; //optional parameter tag
body = body.concat(order);
apiInstance.placeMultiOrder(body, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.MultiOrderRequest;
import com.upstox.api.MultiOrderResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OrderApi;
import java.util.ArrayList;
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();
MultiOrderRequest orderRequest = new MultiOrderRequest();
orderRequest.setQuantity(25);
orderRequest.setProduct(MultiOrderRequest.ProductEnum.D);
orderRequest.setValidity(MultiOrderRequest.ValidityEnum.DAY);
orderRequest.setPrice(0F);
orderRequest.setTag("string");
orderRequest.setInstrumentToken("NSE_FO|44166");
orderRequest.orderType(MultiOrderRequest.OrderTypeEnum.MARKET);
orderRequest.setTransactionType(MultiOrderRequest.TransactionTypeEnum.BUY);
orderRequest.setDisclosedQuantity(0);
orderRequest.setTriggerPrice(0F);
orderRequest.setIsAmo(true);
orderRequest.setCorrelationId("1");
orderRequest.setSlice(false);
try {
ArrayList<MultiOrderRequest> list = new ArrayList<>();
list.add(orderRequest);
MultiOrderResponse result = apiInstance.placeMultiOrder(list);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#MultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Place Multiple BUY and SELL Orders
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/order/multi/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '[
{
"correlation_id": "1",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
},
{
"correlation_id": "2",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "SELL",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
}
]'
'
import requests
url = 'https://api.upstox.com/v2/order/multi/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = [
{
"correlation_id": "1",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": False,
"slice": False
},
{
"correlation_id": "2",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "SELL",
"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.upstox.com/v2/order/multi/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = [
{
"correlation_id": "1",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
},
{
"correlation_id": "2",
"quantity": 25,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "SELL",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": false
}
];
axios.post(url, data, { headers })
.then(response => {
console.log('Response Code:', response.status);
console.log('Response Body:', 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/v2/order/multi/place";
String token = "Bearer {your_access_token}";
// Set up the request body with multiple orders
String requestBody = "["
+ "{"
+ "\"correlation_id\": \"1\","
+ "\"quantity\": 25,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|62864\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": false,"
+ "\"slice\": false"
+ "},"
+ "{"
+ "\"correlation_id\": \"2\","
+ "\"quantity\": 25,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|62867\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"SELL\","
+ "\"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.upstox.com/v2/order/multi/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
// Set up the request body with multiple orders
$data = [
[
"correlation_id" => "1",
"quantity" => 25,
"product" => "D",
"validity" => "DAY",
"price" => 0,
"tag" => "string",
"instrument_token" => "NSE_FO|62864",
"order_type" => "MARKET",
"transaction_type" => "BUY",
"disclosed_quantity" => 0,
"trigger_price" => 0,
"is_amo" => false,
"slice" => false
],
[
"correlation_id" => "2",
"quantity" => 25,
"product" => "D",
"validity" => "DAY",
"price" => 0,
"tag" => "string",
"instrument_token" => "NSE_FO|62867",
"order_type" => "MARKET",
"transaction_type" => "SELL",
"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);
?>
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.MultiOrderRequest(25, "D", "DAY", 0, "string", False, "NSE_FO|44166", "MARKET", "BUY",
0, 0, True, "1"),
upstox_client.MultiOrderRequest(25, "D", "DAY", 0, "string", False, "NSE_FO|44122", "MARKET", "SELL",
0, 0, True, "2")
]
try:
api_response = api_instance.place_multi_order(body)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_order: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
apiInstance = new UpstoxClient.OrderApi();
body = []
buyRequest = new UpstoxClient.MultiOrderRequest(25,"D","DAY",0,false,"NSE_FO|44166","MARKET","BUY",0,0,true,"1");
buyRequest.tag = "string";
sellRequest = new UpstoxClient.MultiOrderRequest(25,"D","DAY",0,false,"NSE_FO|44122","MARKET","SELL",0,0,true,"2");
sellRequest.tag = "string";
body = body.concat(buyRequest, sellRequest);
apiInstance.placeMultiOrder(body, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.MultiOrderRequest;
import com.upstox.api.MultiOrderResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OrderApi;
import java.util.List;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
MultiOrderRequest buyOrderRequest = new MultiOrderRequest();
buyOrderRequest.setQuantity(25);
buyOrderRequest.setProduct(MultiOrderRequest.ProductEnum.D);
buyOrderRequest.setValidity(MultiOrderRequest.ValidityEnum.DAY);
buyOrderRequest.setPrice(0F);
buyOrderRequest.setTag("string");
buyOrderRequest.setInstrumentToken("NSE_FO|44166");
buyOrderRequest.orderType(MultiOrderRequest.OrderTypeEnum.MARKET);
buyOrderRequest.setTransactionType(MultiOrderRequest.TransactionTypeEnum.BUY);
buyOrderRequest.setDisclosedQuantity(0);
buyOrderRequest.setTriggerPrice(0F);
buyOrderRequest.setIsAmo(true);
buyOrderRequest.setCorrelationId("1");
buyOrderRequest.setSlice(false);
MultiOrderRequest sellOrderRequest = new MultiOrderRequest();
sellOrderRequest.setQuantity(25);
sellOrderRequest.setProduct(MultiOrderRequest.ProductEnum.D);
sellOrderRequest.setValidity(MultiOrderRequest.ValidityEnum.DAY);
sellOrderRequest.setPrice(0F);
sellOrderRequest.setTag("string");
sellOrderRequest.setInstrumentToken("NSE_FO|44122");
sellOrderRequest.orderType(MultiOrderRequest.OrderTypeEnum.MARKET);
sellOrderRequest.setTransactionType(MultiOrderRequest.TransactionTypeEnum.SELL);
sellOrderRequest.setDisclosedQuantity(0);
sellOrderRequest.setTriggerPrice(0F);
sellOrderRequest.setIsAmo(true);
sellOrderRequest.setCorrelationId("2");
sellOrderRequest.setSlice(false);
try {
List<MultiOrderRequest> list = List.of(buyOrderRequest, sellOrderRequest);
MultiOrderResponse result = apiInstance.placeMultiOrder(list);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#MultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Place Multiple Orders with Auto Slicing enabled
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/order/multi/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '[
{
"correlation_id": "1",
"quantity": 2500000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": true
},
{
"correlation_id": "2",
"quantity": 2500000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "SELL",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": true
}
]'
'
import requests
url = 'https://api.upstox.com/v2/order/multi/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = [
{
"correlation_id": "1",
"quantity": 2500000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": False,
"slice": True
},
{
"correlation_id": "2",
"quantity": 2500000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "SELL",
"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.upstox.com/v2/order/multi/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = [
{
"correlation_id": "1",
"quantity": 2500000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62864",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": true
},
{
"correlation_id": "2",
"quantity": 2500000,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_FO|62867",
"order_type": "MARKET",
"transaction_type": "SELL",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false,
"slice": true
}
];
axios.post(url, data, { headers })
.then(response => {
console.log('Response Code:', response.status);
console.log('Response Body:', 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/v2/order/multi/place";
String token = "Bearer {your_access_token}";
// Set up the request body with multiple orders
String requestBody = "["
+ "{"
+ "\"correlation_id\": \"1\","
+ "\"quantity\": 2500000,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|62864\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": false,"
+ "\"slice\": true"
+ "},"
+ "{"
+ "\"correlation_id\": \"2\","
+ "\"quantity\": 2500000,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_FO|62867\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"SELL\","
+ "\"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.upstox.com/v2/order/multi/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
// Set up the request body with multiple orders
$data = [
[
"correlation_id" => "1",
"quantity" => 2500000,
"product" => "D",
"validity" => "DAY",
"price" => 0,
"tag" => "string",
"instrument_token" => "NSE_FO|62864",
"order_type" => "MARKET",
"transaction_type" => "BUY",
"disclosed_quantity" => 0,
"trigger_price" => 0,
"is_amo" => false,
"slice" => true
],
[
"correlation_id" => "2",
"quantity" => 2500000,
"product" => "D",
"validity" => "DAY",
"price" => 0,
"tag" => "string",
"instrument_token" => "NSE_FO|62867",
"order_type" => "MARKET",
"transaction_type" => "SELL",
"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);
?>
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.MultiOrderRequest(25, "D", "DAY", 0, "string", True, "NSE_FO|44166", "MARKET", "BUY",
0, 0, True, "1")
]
try:
api_response = api_instance.place_multi_order(body)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_order: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
apiInstance = new UpstoxClient.OrderApi();
body = []
order = new UpstoxClient.MultiOrderRequest(25,"D","DAY",0,true,"NSE_FO|44166","MARKET","BUY",0,0,true,"1");
order.tag = "string"; //optional parameter tag
body = body.concat(order);
apiInstance.placeMultiOrder(body, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.MultiOrderRequest;
import com.upstox.api.MultiOrderResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OrderApi;
import java.util.ArrayList;
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();
MultiOrderRequest orderRequest = new MultiOrderRequest();
orderRequest.setQuantity(25);
orderRequest.setProduct(MultiOrderRequest.ProductEnum.D);
orderRequest.setValidity(MultiOrderRequest.ValidityEnum.DAY);
orderRequest.setPrice(0F);
orderRequest.setTag("string");
orderRequest.setInstrumentToken("NSE_FO|44166");
orderRequest.orderType(MultiOrderRequest.OrderTypeEnum.MARKET);
orderRequest.setTransactionType(MultiOrderRequest.TransactionTypeEnum.BUY);
orderRequest.setDisclosedQuantity(0);
orderRequest.setTriggerPrice(0F);
orderRequest.setIsAmo(true);
orderRequest.setCorrelationId("1");
orderRequest.setSlice(true);
try {
ArrayList<MultiOrderRequest> list = new ArrayList<>();
list.add(orderRequest);
MultiOrderResponse result = apiInstance.placeMultiOrder(list);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#MultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}