Basket margin
Required margin is the amount required to place all the orders in the basket of multiple stocks.
Method: POST
https://connect.thefirstock.com/api/V3/basketMargin
Request details
Parameter | Description | Data types | Example |
---|---|---|---|
userId | Logged in user Id | String | "AA1999" |
data | Noren order number | List | List of data |
jKey | Key obtained on login success. | String | "d1b02fdc270bd03d93926e10633aa00c" |
Request details for Data
Parameter | Description | Data types | Example |
---|---|---|---|
exchange | NSE / NFO / BSE/ MCX | String | "NSC" |
tradingSymbol | Unique id of contract on which order to be placed. (use urlencoding to avoid special char error for symbols like M&M) | String | "SAIL01DEC22P99" |
quantity | Order quantity | String | "1" |
transactionType | B -> BUY, S -> SELL | String | "S" |
price | Order Price | String | "260" |
product | C/M/I C -> Cash and Carry, M -> F&O Normal, I -> Intraday | String | "C" |
priceType | LMT / MKT / SL-LMT / SL-MKT | String | "LMT" |
- cURL
curl --location 'https://connect.thefirstock.com/api/V3/basketMargin' \
--header 'Content-Type: application/json' \
--data '{
"userId": "AA123",
"jKey": "e6a211bea63adff386578988e1cf4a9521c4744e6a39ad63174c8797e2af8c38",
"basket": [
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23P17000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23P17000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
}
]
}'
from thefirstock import thefirstock
basketMargin = thefirstock.firstock_BasketMargin(
basket=[
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23P17000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23C19000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23C19000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
}
]
)
const Firstock = require("thefirstock");
const firstock = new Firstock();
firstock.basketMargin(
{
basket: [
{
exchange: "NSE",
tradingSymbol: "NESTLEIND-EQ",
quantity: "1",
transactionType: "S",
price: "1200",
product: "I",
priceType: "LMT",
},
{
exchange: "NSE",
tradingSymbol: "NESTLEIND-EQ",
quantity: "1",
transactionType: "S",
price: "1300",
product: "I",
priceType: "LMT",
},
],
},
(err, result) => {
console.log("Error, ", err);
console.log("Result: ", result);
}
);
using thefirstock;
class Progrom
{
public static void Main()
{
Firstock firstock = new Firstock();
var result = firstock.basketMargin(basket: new List<basketMarginObject>() {
new basketMarginObject{
exchange="NSE",
tradingSymbol="NESTLEIND-EQ",
quantity="1",
transactionType="S",
price="1200",
product="I",
priceType="LMT",
},
new basketMarginObject{
exchange= "NSE",
tradingSymbol= "NESTLEIND-EQ",
quantity= "1",
transactionType= "S",
price= "1300",
product= "I",
priceType= "LMT",
}
});
}
}
Success response details
Parameter | Description | Data types | Examples |
---|---|---|---|
status | Success | String | "Success" |
data.request_time | Response received time. | String | "18:00:27 16-02-2023" |
data.remarks | This field will contain rejection reason. | String | "basketMargin" |
data.marginused | Total margin used. | String | "19150.45" |
data.marginusedtrade | Margin used after trade | String | "22.95" |
data.stat | This will be present only if Order placement fails | String | "ok" |
Failure response details
Parameter | Description | Data Type | Example |
---|---|---|---|
status | Failed | String | "Failed" |
code | HTTP Code | String | "401" |
name | Type of error | String | "INVALID_USERID" |
error.field | Error field | String | "userid" |
error.message | Error message | String | "userid parameter is invalid" |
Sample response
- Success response
- Failure Response
{
"status": "Success",
"data": {
"request_time": "18:00:27 16-02-2023",
"stat": "Ok",
"marginused": "19150.45",
"marginusedtrade": "22.95",
"remarks": "basketMargin"
}
}
{
"status": "Failed",
"code": "401",
"name": "INVALID_USERID",
"error": {
"field": "userid",
"message": "userid parameter is invalid"
}
}