Calculate Order Margin
Calculate Order Margin APIs
method | path | description |
---|---|---|
POST | https://api.mstock.trade/openapi/typea/margins/orders | This endpoint allows users to retrieve a list of their trading orders. Users can view all their existing orders. |
Calculate Order Margin
This endpoint allows users to retrieve a list of their trading orders. Users can view all their existing orders.
Request Headers -
-
X-Mirae-Version : Specifies the version of the API being used. In this case, it is set to 1.
-
Authorization : A token-based authentication header. The format is token api_key:access_token.
-
Content-Type : Indicated the media type of the resource. For this request, it is set to application/x-www-form-urlencoded, which is used for submiting form data.
curl --location 'https://api.mstock.trade/openapi/typea/margins/orders' \
--header 'X-Mirae-Version: 1' \
--header 'Authorization: token api_key:access_token' \
--header 'Content-Type: application/json' \
--data '{
"exchange": "NSE",
"tradingsymbol": "INFY",
"transaction_type": "BUY",
"variety": "regular",
"product": "CNC",
"order_type": "MARKET",
"quantity": 1,
"price": 0,
"trigger_price": 0
}'
import axios from 'axios';
const response = await axios.post(
'https://api.mstock.trade/openapi/typea/margins/orders',
// '{\n "exchange": "NSE",\n "tradingsymbol": "INFY",\n "transaction_type": "BUY",\n "variety": "regular",\n "product": "CNC",\n "order_type": "MARKET",\n "quantity": 1,\n "price": 0,\n "trigger_price": 0\n}',
{
'exchange': 'NSE',
'tradingsymbol': 'INFY',
'transaction_type': 'BUY',
'variety': 'regular',
'product': 'CNC',
'order_type': 'MARKET',
'quantity': 1,
'price': 0,
'trigger_price': 0
},
{
headers: {
'X-Mirae-Version': '1',
'Authorization': 'token api_key:access_token',
'Content-Type': 'application/json'
}
}
);
import http.client
import json
conn = http.client.HTTPConnection('api.mstock.trade')
headers = {
'X-Mirae-Version': '1',
'Authorization': 'token api_key:access_token',
'Content-Type': 'application/json',
}
json_data = {
'exchange': 'NSE',
'tradingsymbol': 'INFY',
'transaction_type': 'BUY',
'variety': 'regular',
'product': 'CNC',
'order_type': 'MARKET',
'quantity': 1,
'price': 0,
'trigger_price': 0,
}
conn.request(
'POST',
'openapi/typea/margins/orders',
json.dumps(json_data),
# '{\n "exchange": "NSE",\n "tradingsymbol": "INFY",\n "transaction_type": "BUY",\n "variety": "regular",\n "product": "CNC",\n "order_type": "MARKET",\n "quantity": 1,\n "price": 0,\n "trigger_price": 0\n}',
headers
)
response = conn.getresponse()
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NORMAL)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mstock.trade/openapi/typea/margins/orders"))
.POST(BodyPublishers.ofString("{\n \"exchange\": \"NSE\",\n \"tradingsymbol\": \"INFY\",\n \"transaction_type\": \"BUY\",\n \"variety\": \"regular\",\n \"product\": \"CNC\",\n \"order_type\": \"MARKET\",\n \"quantity\": 1,\n \"price\": 0,\n \"trigger_price\": 0\n}"))
.setHeader("X-Mirae-Version", "1")
.setHeader("Authorization", "token api_key:access_token")
.setHeader("Content-Type", "application/json")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request Body -
{
"exchange": "NSE",
"tradingsymbol": "INFY",
"transaction_type": "BUY",
"variety": "regular",
"product": "CNC",
"order_type": "MARKET",
"quantity": 1,
"price": 0,
"trigger_price": 0
}
Response Structure -
The response of the request will be based on authentication outcome.
- Success (HTTP Status 200): On successful request execution, server will return the below json formated data.
{
"status": "success",
"data": {
"type": "equity",
"tradingsymbol": "INFY",
"exchange": "NSE",
"span": 0,
"exposure": 0,
"option_premium": 0,
"additional": 1699.37,
"bo": 0,
"cash": 0,
"var": 0,
"pnl": {
"realised": 0,
"unrealised": 0
},
"leverage": 0,
"charges": {
"transaction_tax": 0,
"transaction_tax_type": "stt",
"exchange_turnover_charge": 0,
"sebi_turnover_charge": 0,
"brokerage": 80.92,
"stamp_duty": 0,
"gst": {
"igst": 0,
"cgst": 0,
"sgst": 0,
"total": 0
},
"total": 80.92
},
"total": 1699.37
}
}
- Failure (HTTP Status 200): If authentication fails, the server will return an error message
{
"status": "error",
"message": "Incorrect auth. Please try again.",
"error_type": "InputException",
"data": null
}
{
"status": "error",
"message": "API is suspended/expired for use. Please check your API subscription and try again.",
"error_type": "APIKeyException",
"data": null
}