# Order Margin

Endpoint

{% code title="Base URL" overflow="wrap" fullWidth="false" %}

```
https://connects.torusdigital.com/api/v1/order/calculate/margin
```

{% endcode %}

#### Header Parameters <a href="#header-parameters" id="header-parameters"></a>

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

#### **Request Parameter**

<table><thead><tr><th width="148">Parameter</th><th width="206">Sample/Possible Value</th><th width="126">Mandatory</th><th>Remarks</th></tr></thead><tbody><tr><td>exchange</td><td>NSE</td><td>Y</td><td>Exchange</td></tr><tr><td>segment</td><td>E</td><td>Y</td><td>In Segment E stands for Equity</td></tr><tr><td>security_id</td><td>1996</td><td>Y</td><td>Security ID</td></tr><tr><td>txn_type</td><td>B</td><td>Y</td><td>Transaction Type</td></tr><tr><td>totalremqty</td><td>9</td><td>Y</td><td>Quantity</td></tr><tr><td>price</td><td>0.00</td><td>Y</td><td>Order price (for market pass 0)</td></tr><tr><td>product</td><td>C</td><td>Y</td><td>Product</td></tr><tr><td>trigger_price</td><td>10.00</td><td>Y</td><td>Trigger price (In case of CO this value should be trigger price of SL leg and in case of BO this value should be absolute)</td></tr></tbody></table>

#### **Request**

{% tabs %}
{% tab title="curl" %}
{% code title="cURL" overflow="wrap" lineNumbers="true" %}

```javascript
curl --location 'https://connects.torusdigital.com/api/v1/order/calculate/margin' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
    "source": "A",
    "data": {
        "security_id": "14366",
        "product": "B",
        "segment": "E",
        "exchange": "NSE",
        "totalremqty": "1",
        "price": "13.00",
        "txn_type": "B",
        "trigger_price":"13.10"
    }
}'
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code title="Java-Unirest" fullWidth="false" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://connects.torusdigital.com/api/v1/order/calculate/margin")
  .header("Authorization", "Bearer {{token}}")
  .header("Content-Type", "application/json")
  .body("{\n" +
        "    \"source\": \"A\",\n" +
        "    \"data\": {\n" +
        "        \"security_id\": \"14366\",\n" +
        "        \"product\": \"B\",\n" +
        "        \"segment\": \"E\",\n" +
        "        \"exchange\": \"NSE\",\n" +
        "        \"totalremqty\": \"1\",\n" +
        "        \"price\": \"13.00\",\n" +
        "        \"txn_type\": \"B\",\n" +
        "        \"trigger_price\": \"13.10\"\n" +
        "    }\n" +
        "}")
  .asString();
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code title="Go-Native" overflow="wrap" lineNumbers="true" fullWidth="true" %}

```go
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
)

func main() {
	url := "https://connects.torusdigital.com/api/v1/order/calculate/margin"
	method := "POST"

	payload := strings.NewReader(`{
    "source": "A",
    "data": {
        "security_id": "14366",
        "product": "B",
        "segment": "E",
        "exchange": "NSE",
        "totalremqty": "1",
        "price": "13.00",
        "txn_type": "B",
        "trigger_price": "13.10"
    }
}`)

	client := &http.Client{}
	req, err := http.NewRequest(method, url, payload)

	if err != nil {
		fmt.Println(err)
		return
	}
	req.Header.Add("Authorization", "Bearer {{token}}")
	req.Header.Add("Content-Type", "application/json")

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer res.Body.Close()

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(body))
}
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code title="JavaScript-jQuery" overflow="wrap" lineNumbers="true" %}

```javascript
var settings = {
  "url": "https://connects.torusdigital.com/api/v1/order/calculate/margin",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer {{token}}",
    "Content-Type": "application/json"
  },
  "data": JSON.stringify({
    "source": "A",
    "data": {
      "security_id": "14366",
      "product": "B",
      "segment": "E",
      "exchange": "NSE",
      "totalremqty": "1",
      "price": "13.00",
      "txn_type": "B",
      "trigger_price": "13.10"
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "data": [
        {
            "INSFFBALNC": 0.0,
            "VARELMMARGIN": 0.0,
            "AVAILBALANCE": 10000000.0,
            "BROKERAGE": 0.0,
            "TOTMARGIN": 5292.0,
            "EXPOMARGIN": 0.0,
            "SPANMARGIN": 0.0,
            "BROKER_BROKERAGE": 600,
            "LEVIES_BROKERAGE": 0,
            "OTHER_BROKERAGE": 0
        }
    ],
    "status": "success",
    "message": "Success"
}
```

{% endtab %}
{% endtabs %}

**Response Parameter**

| Field             | Description                                                                                                       |
| ----------------- | ----------------------------------------------------------------------------------------------------------------- |
| INSFFBALNC        | Insufficient balance in the account (floating-point number).                                                      |
| VARELMMARGIN      | Variation margin, the funds required to bring the margin balance up to the initial margin during the trading day. |
| AVAILBALANCE      | Available balance in the account (floating-point number).                                                         |
| BROKERAGE         | Brokerage fee charged for executing trades or services (floating-point number).                                   |
| TOTMARGIN         | Total margin held in the account, typically required for trading derivatives (floating-point number).             |
| EXPOMARGIN        | Exposure margin required for exposure to risks (floating-point number).                                           |
| SPANMARGIN        | SPAN margin determined by exchanges for futures/options contracts (floating-point number).                        |
| BROKER\_BROKERAGE | Specific type of brokerage fee (integer).                                                                         |
| LEVIES\_BROKERAGE | Levies or additional charges associated with brokerage (integer).                                                 |
| OTHER\_BROKERAGE  | Other brokerage-related charges or fees (integer).                                                                |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heytorus.gitbook.io/torus-digital-open-api/orders/order-margin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
