Skip to main content

Order & Report

Order Margin

Margin trading refers to the activity of buying or selling where an individual increases his/her possible returns on investment by investing more than they can afford to

Before placing your order, you have the option to review the margin requirement for your selected order.

Method: POST

https://connect.thefirstock.com/api/V4/orderMargin

Request details

API Parameters
Parameter Description Example
userId
String
Identifier for the user upon login, unique
to each user in the system.
AA0013
exchange
String
Specifies the exchange platform
(NSE, NFO, BSE, BFO)
NSE
tradingSymbol
String
Encoded trading symbol of the
security or instrument
ITC-EQ
quantity
String
Number of shares or units to be traded 10
price
String
Price at which the order is to be executed 260
product
String
Type of financial product
(C: Cash and Carry, M: F&O Normal, I: Intraday)
C
transactionType
String
Transaction type
Buy (B) or Sell (S)
B
priceType
String
Type of pricing for the order
(e.g., LMT, MKT, SL-LMT, SL-MKT)
LMT
jKey
String
Authentication token obtained from the login API d9b4e1b1c79042476fd9611eed

Libraries and SDKs

Tabbed Interface
from thefirstock import thefirstock

orderMargin = thefirstock.firstock_orderMargin(
    userId="{{userId}}",
    exchange="NSE",
    tradingSymbol="ITC-EQ",
    quantity="1",
    priceType="LMT",
    product="C",
    price="350",
    transactionType="B"
)
curl --location --request POST 'https://connect.thefirstock.com/api/V4/orderMargin' \
--header 'Content-Type: application/json' \
--data-raw '{
    "userId": "{{userId}}",
    "exchange": "NSE", 
    "tradingSymbol": "ITC-EQ",
    "quantity": "250",
    "price": "413",
    "product": "C",
    "transactionType": "B",
    "priceType": "LMT",
    "jKey": "{{jKey}}"
}'code>
const Firstock = require("thefirstock");

const firstock = new Firstock();

firstock.orderMargin(
  {
    userId: {{userId}},
    exchange: "NSE",
    tradingSymbol: "ITC-EQ",
    quantity: "1",
    price: "350",
    product: "I",
    transactionType: "B",
    priceType: "LMT",
  },
  (err, result) => {
    console.log("Error, ", err);
    console.log("Result: ", result);
  }
);
using thefirstock;

class Program
{
    public static void Main()
    {
        Firstock firstock = new Firstock();
        var result = firstock.orderMargin(
            userId: {{userId}},
            exchange: "NSE",
            tradingSymbol: "ITC-EQ",
            quantity: "10",
            price: "260",
            product: "C",
            transactionType: "B",
            priceType: "LMT"
          );
    }
}

Success response details

API Parameters
Parameter Description Example
status
String
Indicates the outcome of the API request success
data.requestTime
String
Timestamp indicating when the response
was received
14:31:41 15-02-2023
data.cash
String
Available balance of the user -141.37
data.marginused
String
Amount of margin used 523.05
data.remarks
String
Additional information or comments,
available on success
Insufficient Balance
{  
  "status": "success",  
  "data": {    
    "requestTime": "14:31:41 15-02-2023", 
    "cash": "-141.37", 
    "marginused": "523.05",  
    "remarks": "Insufficient Balance"  
  }
}

Failure response details

API Error Parameters
Parameter Description Data Type Example
status
String
Indicates the result status
of the API operation
String failed
code
String
HTTP status code associated
with the error
String 401
name
String
Specifies the type or category
of the error encountered
String INVALID_USERID
error.field
String
Field in the request that triggered
the error
String userid
error.message
String
Detailed message describing
the error
String userid parameter is invalid
{ 
  "status": "failed",
  "code": "401",
  "name": "INVALID_USERID",  
  "error": {    
      "field": "userid", 
      "message": "userid parameter is invalid" 
  }
}