Skip to content

Contract Analyser

POST /contractsAnalyser

The Contact Analyzer API serves as an indispensable tool for traders and financial analysts seeking to evaluate and optimize intricate trading strategies involving multiple contracts, particularly in the realm of options trading. By delivering a comprehensive and detailed report that covers both performance metrics and risk assessments, the API enables users to gain profound insights into the nuances of their strategies. It provides critical data such as breakeven points, maximum profit, maximum loss, strategy Greeks, risk-reward ratio, estimated margins, and payoff points, accompanied by graphs. This empowers users to make well-informed, data-driven decisions with confidence. By offering an in-depth breakdown of every critical aspect of the strategy, including potential profits, losses, risk parameters, and various payoff scenarios, the Contact Analyzer API becomes an essential resource for those striving to enhance their decision-making processes in the complex and dynamic landscape of financial markets.

Parameter

NameTypeRequiredDescription
exchangestringtrueSpecifies the exchange where the contracts are traded. Valid values: NFO, BFO.
contractsobjecttrueA list of contract details being analyzed.
tradingSymbolstringtrueThe symbol representing the contract.
transactionTypestringtrueThe type of transaction, either "Buy" or "Sell."
pricestringtrueThe price at which the contract is being traded.
lotstringtrueThe number of lots associated with the contract.
targetDatestringtrueThe date for which the analysis is being performed.

Sample Request Body

json

requestBody={
    "exchange": "NFO",
    "contracts": [
        {
            "tradingSymbol": "HDFCBANK24OCT1510CE",
            "transactionType": "Buy",
            "price": "152.75",
            "lot": "2"
        },
        {
            "tradingSymbol": "HDFCBANK24SEP1510CE",
            "transactionType": "SELL",
            "price": "1342.75",
            "lot": "2"
        }
    ],
    "targetDate": "2024-10-11"
}

Sample Code

bash
curl -X POST 'https://tradeapi.samco.in/contractsAnalyser' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"exchange":"NFO","contracts":[{"tradingSymbol":"HDFCBANK24OCT1510CE","transactionType":"Buy","price":"152.75","lot":"2"},{"tradingSymbol":"HDFCBANK24SEP1510CE","transactionType":"SELL","price":"1342.75","lot":"2"}],"targetDate":"2024-10-11"}'
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Sample {
  public static void main(String[] args) throws Exception {
    String requestBody = """
        {
          "exchange": "NFO",
          "contracts": [
            {
              "tradingSymbol": "HDFCBANK24OCT1510CE",
              "transactionType": "Buy",
              "price": "152.75",
              "lot": "2"
            },
            {
              "tradingSymbol": "HDFCBANK24SEP1510CE",
              "transactionType": "SELL",
              "price": "1342.75",
              "lot": "2"
            }
          ],
          "targetDate": "2024-10-11"
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/contractsAnalyser"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
        .build();

    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
  }
}
js
(async () => {
  const headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'x-session-token': '<SESSION_TOKEN>',
  };

  const requestBody = {
    exchange: "NFO",
    contracts: [
      {
        tradingSymbol: "HDFCBANK24OCT1510CE",
        transactionType: "Buy",
        price: "152.75",
        lot: "2"
      },
      {
        tradingSymbol: "HDFCBANK24SEP1510CE",
        transactionType: "SELL",
        price: "1342.75",
        lot: "2"
      }
    ],
    targetDate: "2024-10-11"
  };

  const response = await fetch('https://tradeapi.samco.in/contractsAnalyser', {
    method: 'POST',
    headers,
    body: JSON.stringify(requestBody),
  });

  const data = await response.json();
  console.log(data);
})();
py
import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': '<SESSION_TOKEN>',
}

requestBody = {
  "exchange": "NFO",
  "contracts": [
    {
      "tradingSymbol": "HDFCBANK24OCT1510CE",
      "transactionType": "Buy",
      "price": "152.75",
      "lot": "2"
    },
    {
      "tradingSymbol": "HDFCBANK24SEP1510CE",
      "transactionType": "SELL",
      "price": "1342.75",
      "lot": "2"
    }
  ],
  "targetDate": "2024-10-11"
}

r = requests.post('https://tradeapi.samco.in/contractsAnalyser',
  data=json.dumps(requestBody),
  headers=headers)

print(r.json())

Sample Response

json
{
    "serverTime": "09/09/24 12:16:08",
    "msgId": "cc1569f6-e666-4759-8590-4fefa538ce4e",
    "status": "Success",
    "statusMessage": "Contracts analysis report is successfully generated.",
    "analyseReport": {
        "strategyInfo": {
            "symbol": "1333_NSE",
            "symbolName": "HDFCBANK",
            "change": "2.45",
            "changePer": "0.15",
            "exchange": "NSE",
            "noOfStrategyLegs": 2,
            "strategyLegs": [
                {
                    "tradingSymbol": "HDFCBANK24OCT1510CE",
                    "symName": "HDFCBANK",
                    "symbol": "107396_NFO",
                    "optionType": "CE",
                    "instrument": "OPTSTK",
                    "expiry": "31 Oct 24",
                    "lotSize": "550",
                    "quantity": "1100",
                    "lTP": "165.55",
                    "avgPrc": "152.75",
                    "askPrice": "0.00",
                    "bidPrice": "0.00",
                    "openInterest": "0",
                    "strategyLegType": "LONG CALL",
                    "strategyExpiryType": "Next expiry",
                    "upperCktLimit": "16555.00",
                    "lowerCktLimit": "0.05",
                    "tickSize": "0.05"
                },
                {
                    "tradingSymbol": "HDFCBANK24SEP1510CE",
                    "symName": "HDFCBANK",
                    "symbol": "78225_NFO",
                    "optionType": "CE",
                    "instrument": "OPTSTK",
                    "expiry": "26 Sep 24",
                    "lotSize": "550",
                    "quantity": "1100",
                    "lTP": "148.8",
                    "avgPrc": "1342.75",
                    "askPrice": "0.00",
                    "bidPrice": "0.00",
                    "openInterest": "0",
                    "strategyLegType": "SHORT CALL",
                    "strategyExpiryType": "Current expiry",
                    "upperCktLimit": "14880.00",
                    "lowerCktLimit": "0.05",
                    "tickSize": "0.05"
                }
            ],
            "breakeven1": "NA",
            "breakeven2": "0.00",
            "maxProfit": "13,49,308",
            "sMaxProfit": "13,49,308(1265%)",
            "maxLoss": "13,10,536",
            "sMaxLoss": "13,10,536(1229%)",
            "sNetTheta": "0.000000",
            "sNetDelta": "0.000000",
            "sNetGamma": "0.000000",
            "sNetVega": "0.000000",
            "sRRRatio": "1: 1.03",
            "estimatedMargin": "1,06,632.57",
            "targetExpiryDate": "26 Sep 24",
            "lotSize": "550",
            "plDataByPricePointPayoffChart": [
                {
                    "pricePoint": 1380,
                    "pricePointProfitLoss": 1310536,
                    "pricePointProfitLossOnUserExpiry": 1309155
                },
                {
                    "pricePoint": 1381,
                    "pricePointProfitLoss": 1310582,
                    "pricePointProfitLossOnUserExpiry": 1309161
                },
                {
                    "pricePoint": 1382,
                    "pricePointProfitLoss": 1310630,
                    "pricePointProfitLossOnUserExpiry": 1309169
                },
                {
                    "pricePoint": 1382,
                    "pricePointProfitLoss": 1310678,
                    "pricePointProfitLossOnUserExpiry": 1309176
                }
            ]
        }
    }
}
json
{
  "serverTime": "14/05/24 13:49:07",
  "status": "Failure",
  "statusMessage": "No Symbol found for the provided symbol name and exchange."
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringThe timestamp of when the response was generated, indicating the server's current time.
msgIdstringA unique identifier for the request, useful for tracking and debugging.
statusstringThe status of the API response. It can be either 'Success', 'Error', or 'Failure'.
statusMessagestringA message providing additional details about the status of the request.
analyseReportObjectThe core of the response containing the detailed analysis of the strategy.
strategyInfoObjectA summary of the strategy being analyzed.
symbolstringAn internal symbol code used by the system to represent the strategy.
symbolNamestringThe name of the underlying asset in the strategy.
changestringThe change in price for the underlying asset.
changePerstringThe percentage change in price for the underlying asset.
exchangestringThe exchange where the asset is listed.
noOfStrategyLegsstringThe number of legs or positions in the strategy. A strategy can involve multiple contracts (legs).
strategyLegsarrayDetails of each leg in the strategy.
tradingSymbolstringThe symbol of the contract.
symNamestringThe underlying asset's name.
symbolstringThe internal symbol code used by the system.
optionTypestringThe type of option (e.g., Call (CE) or Put (PE)).
instrumentstringThe type of financial instrument.
expirystringThe expiry date of the contract.
lotSizestringThe number of units in a lot.
quantitystringTotal quantity involved in the leg (lot size * lots).
lTPstringThe last traded price of the contract.
avgPrcstringThe average price at which the contract was executed.
askPricestringThe current ask price.
bidPricestringThe current bid price.
openIntereststringThe current open interest of the contract.
strategyLegTypestringThe type of leg (e.g., "LONG CALL" or "SHORT CALL").
strategyExpiryTypestringIndicates whether the expiry is current or next.
upperCktLimitstringThe upper circuit limit of the contract.
lowerCktLimitstringThe lower circuit limit of the contract.
tickSizestringThe minimum price movement of the contract.
breakeven1stringThe first breakeven point for the strategy, representing the price level where neither profit nor loss is made.
breakeven2stringThe second breakeven point, set at "0.00" here.
maxProfitstringThe maximum profit that can be achieved with the strategy.
sMaxProfitstringThe maximum profit shown with the percentage of profit relative to the investment.
maxLossstringThe maximum potential loss with the strategy.
sMaxLossstringThe maximum loss shown with the percentage of loss relative to the investment.
sNetThetastringThe net Theta of the strategy, representing the time decay of options.
sNetDeltastringThe net Delta of the strategy, representing the price sensitivity to the underlying asset.
sNetGammastringThe net Gamma of the strategy, representing the rate of change of Delta.
sNetVegastringThe net Vega of the strategy, representing the sensitivity to volatility.
sRRRatiostringThe risk-reward ratio of the strategy.
estimatedMarginstringThe estimated margin required to execute the strategy.
targetExpiryDatestringThe target expiry date for the strategy.
lotSizestringThe lot size used in the strategy.
plDataByPricePointPayoffChartarrayAn array of objects representing the profit/loss at different price points.
pricePointstringThe price point of the underlying asset.
pricePointProfitLossstringThe profit or loss at that price point.
pricePointProfitLossOnUserExpirystringThe profit or loss at that price point on the user-defined expiry date.