Place Order
Place a delivery market order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_EQ|INE669E01016",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'D',
'validity': 'DAY',
'price': 0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE669E01016',
'order_type': 'MARKET',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 0,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'D',
validity: 'DAY',
price: 0,
tag: 'string',
instrument_token: 'NSE_EQ|INE669E01016',
order_type: 'MARKET',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 0,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE669E01016\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'D',
'validity' => 'DAY',
'price' => 0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE669E01016',
'order_type' => 'MARKET',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 0,
'is_amo' => 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.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.D, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 0.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.MARKET,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 0.0, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.D);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(0F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE669E01016");
body.orderType(PlaceOrderRequest.OrderTypeEnum.MARKET);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(0F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place a delivery limit order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "D",
"validity": "DAY",
"price": 13,
"tag": "string",
"instrument_token": "NSE_EQ|INE669E01016",
"order_type": "LIMIT",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 13.2,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'D',
'validity': 'DAY',
'price': 13,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE669E01016',
'order_type': 'LIMIT',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 13.2,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'D',
validity: 'DAY',
price: 13,
tag: 'string',
instrument_token: 'NSE_EQ|INE669E01016',
order_type: 'LIMIT',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 13.2,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 13,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE669E01016\","
+ "\"order_type\": \"LIMIT\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 13.2,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'D',
'validity' => 'DAY',
'price' => 13,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE669E01016',
'order_type' => 'LIMIT',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 13.2,
'is_amo' => 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.PlaceOrderRequest(1, "D", "DAY", 20.0, "string", "NSE_EQ|INE528G01035", "LIMIT", "BUY", 0, 20.1, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.D, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 20.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.LIMIT,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 20.1, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.D);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(14F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE669E01016");
body.orderType(PlaceOrderRequest.OrderTypeEnum.LIMIT);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(14.1F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place a delivery stop-loss order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "D",
"validity": "DAY",
"price": 14.05,
"tag": "string",
"instrument_token": "NSE_EQ|INE669E01016",
"order_type": "SL",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 13,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'D',
'validity': 'DAY',
'price': 14.05,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE669E01016',
'order_type': 'SL',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 13,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'D',
validity: 'DAY',
price: 14.05,
tag: 'string',
instrument_token: 'NSE_EQ|INE669E01016',
order_type: 'SL',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 13,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 14.05,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE669E01016\","
+ "\"order_type\": \"SL\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 13,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'D',
'validity' => 'DAY',
'price' => 14.05,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE669E01016',
'order_type' => 'SL',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 13,
'is_amo' => 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.PlaceOrderRequest(1, "D", "DAY", 20, "string", "NSE_EQ|INE528G01035", "SL", "BUY", 0, 19.5, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.D, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 20.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.SL,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 19.5, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.D);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(14F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE669E01016");
body.orderType(PlaceOrderRequest.OrderTypeEnum.SL);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(13.1F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place a delivery stop-loss order market
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_EQ|INE669E01016",
"order_type": "SL-M",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 15,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'D',
'validity': 'DAY',
'price': 0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE669E01016',
'order_type': 'SL-M',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 15,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'D',
validity: 'DAY',
price: 0.0,
tag: 'string',
instrument_token: 'NSE_EQ|INE669E01016',
order_type: 'SL-M',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 15,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0.0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE669E01016\","
+ "\"order_type\": \"SL-M\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 15,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'D',
'validity' => 'DAY',
'price' => 0.0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE669E01016',
'order_type' => 'SL-M',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 15,
'is_amo' => 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.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "SL-M", "BUY", 0, 21.5, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.D, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 0.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.SL_M,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 24.5, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.D);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(0F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE669E01016");
body.orderType(PlaceOrderRequest.OrderTypeEnum.SL_M);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(15.1F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place an intraday market order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "I",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_EQ|INE528G01035",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'I',
'validity': 'DAY',
'price': 0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE528G01035',
'order_type': 'MARKET',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 0,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'I',
validity: 'DAY',
price: 0.0,
tag: 'string',
instrument_token: 'NSE_EQ|INE528G01035',
order_type: 'MARKET',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 0,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"I\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0.0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE528G01035\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'I',
'validity' => 'DAY',
'price' => 0.0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE528G01035',
'order_type' => 'MARKET',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 0,
'is_amo' => 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.PlaceOrderRequest(1, "I", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.I, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 0.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.MARKET,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 0.0, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.I);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(0F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE528G01035");
body.orderType(PlaceOrderRequest.OrderTypeEnum.MARKET);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(0F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place an intraday limit order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "I",
"validity": "DAY",
"price": 20.0,
"tag": "string",
"instrument_token": "NSE_EQ|INE528G01035",
"order_type": "LIMIT",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 20.1,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'I',
'validity': 'DAY',
'price': 20.0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE528G01035',
'order_type': 'LIMIT',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 20.1,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'I',
validity: 'DAY',
price: 20.0,
tag: 'string',
instrument_token: 'NSE_EQ|INE528G01035',
order_type: 'LIMIT',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 20.1,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"I\","
+ "\"validity\": \"DAY\","
+ "\"price\": 20.0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE528G01035\","
+ "\"order_type\": \"LIMIT\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 20.1,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'I',
'validity' => 'DAY',
'price' => 20.0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE528G01035',
'order_type' => 'LIMIT',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 20.1,
'is_amo' => 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.PlaceOrderRequest(1, "I", "DAY", 20.0, "string", "NSE_EQ|INE528G01035", "LIMIT", "BUY", 0, 20.1, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.I, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 20.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.LIMIT,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 20.1, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.I);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(24F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE528G01035");
body.orderType(PlaceOrderRequest.OrderTypeEnum.LIMIT);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(24.1F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place an intraday stop-loss order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "I",
"validity": "DAY",
"price": 20.0,
"tag": "string",
"instrument_token": "NSE_EQ|INE528G01035",
"order_type": "SL",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 19.5,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'I',
'validity': 'DAY',
'price': 20.0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE528G01035',
'order_type': 'SL',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 19.5,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'I',
validity: 'DAY',
price: 20.0,
tag: 'string',
instrument_token: 'NSE_EQ|INE528G01035',
order_type: 'SL',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 19.5,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"I\","
+ "\"validity\": \"DAY\","
+ "\"price\": 20.0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE528G01035\","
+ "\"order_type\": \"SL\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 19.5,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'I',
'validity' => 'DAY',
'price' => 20.0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE528G01035',
'order_type' => 'SL',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 19.5,
'is_amo' => 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.PlaceOrderRequest(1, "I", "DAY", 20, "string", "NSE_EQ|INE528G01035", "SL", "BUY", 0, 19.5, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.I, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 20.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.SL,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 19.5, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.I);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(24F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE528G01035");
body.orderType(PlaceOrderRequest.OrderTypeEnum.SL);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(23F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place an intraday stop-loss market order
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "I",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_EQ|INE528G01035",
"order_type": "SL-M",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 21.5,
"is_amo": false
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'I',
'validity': 'DAY',
'price': 0.0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE528G01035',
'order_type': 'SL-M',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 21.5,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'I',
validity: 'DAY',
price: 0.0,
tag: 'string',
instrument_token: 'NSE_EQ|INE528G01035',
order_type: 'SL-M',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 21.5,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"I\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0.0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE528G01035\","
+ "\"order_type\": \"SL-M\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 21.5,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'I',
'validity' => 'DAY',
'price' => 0.0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE528G01035',
'order_type' => 'SL-M',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 21.5,
'is_amo' => 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.PlaceOrderRequest(1, "I", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "SL-M", "BUY", 0, 21.5, False)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.I, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 0.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.SL_M,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 24.5, false);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.I);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(0F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE528G01035");
body.orderType(PlaceOrderRequest.OrderTypeEnum.SL_M);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(25F);
body.setIsAmo(false);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}
Place a delivery market amo (after market order)
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api-hft.upstox.com/v2/order/place' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '{
"quantity": 1,
"product": "D",
"validity": "DAY",
"price": 0,
"tag": "string",
"instrument_token": "NSE_EQ|INE669E01016",
"order_type": "MARKET",
"transaction_type": "BUY",
"disclosed_quantity": 0,
"trigger_price": 0,
"is_amo": true
}'
import requests
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
data = {
'quantity': 1,
'product': 'D',
'validity': 'DAY',
'price': 0,
'tag': 'string',
'instrument_token': 'NSE_EQ|INE669E01016',
'order_type': 'MARKET',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 0,
'is_amo': 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/v2/order/place';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
const data = {
quantity: 1,
product: 'D',
validity: 'DAY',
price: 0,
tag: 'string',
instrument_token: 'NSE_EQ|INE669E01016',
order_type: 'MARKET',
transaction_type: 'BUY',
disclosed_quantity: 0,
trigger_price: 0,
is_amo: 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/v2/order/place";
String token = "Bearer {your_access_token}";
// Set up the request body
String requestBody = "{"
+ "\"quantity\": 1,"
+ "\"product\": \"D\","
+ "\"validity\": \"DAY\","
+ "\"price\": 0,"
+ "\"tag\": \"string\","
+ "\"instrument_token\": \"NSE_EQ|INE669E01016\","
+ "\"order_type\": \"MARKET\","
+ "\"transaction_type\": \"BUY\","
+ "\"disclosed_quantity\": 0,"
+ "\"trigger_price\": 0,"
+ "\"is_amo\": 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/v2/order/place';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$data = [
'quantity' => 1,
'product' => 'D',
'validity' => 'DAY',
'price' => 0,
'tag' => 'string',
'instrument_token' => 'NSE_EQ|INE669E01016',
'order_type' => 'MARKET',
'transaction_type' => 'BUY',
'disclosed_quantity' => 0,
'trigger_price' => 0,
'is_amo' => 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.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, True)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_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.PlaceOrderRequest(1, UpstoxClient.PlaceOrderRequest.ProductEnum.D, UpstoxClient.PlaceOrderRequest.ValidityEnum.DAY, 0.0, "NSE_EQ|INE528G01035",UpstoxClient.PlaceOrderRequest.OrderTypeEnum.MARKET,UpstoxClient.PlaceOrderRequest.TransactionTypeEnum.BUY, 0, 0.0, true);
let apiVersion = "2.0";
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error.response.text);
} 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.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
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();
PlaceOrderRequest body = new PlaceOrderRequest();
body.setQuantity(1);
body.setProduct(PlaceOrderRequest.ProductEnum.D);
body.setValidity(PlaceOrderRequest.ValidityEnum.DAY);
body.setPrice(0F);
body.setTag("string");
body.setInstrumentToken("NSE_EQ|INE669E01016");
body.orderType(PlaceOrderRequest.OrderTypeEnum.MARKET);
body.setTransactionType(PlaceOrderRequest.TransactionTypeEnum.BUY);
body.setDisclosedQuantity(0);
body.setTriggerPrice(0F);
body.setIsAmo(true);
String apiVersion = "2.0"; // String | API Version Header
try {
PlaceOrderResponse result = apiInstance.placeOrder(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#placeOrder ");
e.printStackTrace();
}
}
}