Calculating margin quantity using a fixed amount

thepunisher
This question is regarding Intraday equity margin calculation - https://kite.trade/docs/connect/v3/margins/

The margin calculation API takes in the symbol, quantity and some other parameters and returns the margin amount. What I want to do is to specify a fixed amount and find out how many shares I can buy using margin.

Example, I have Rs. 50,000 to trade and I'd like to know how much quantities of SBIN I can buy with it.

What I'm planning to do is to send a single quantity request like this:
curl -s https://api.kite.trade/margins/orders \
-H 'X-Kite-Version: 3' \
-H 'Authorization: token xxx:yyy' \
-H 'Content-Type: application/json' \
-d '[
{
"exchange": "NSE",
"tradingsymbol": "SBIN",
"transaction_type": "BUY",
"variety": "bo",
"product": "MIS",
"order_type": "SL-M",
"quantity": 1,
"stoploss": 1,
"squareoff": 2
}
]'
and divide 50000 by the margin amount returned to get the quantity. Is there a better way to do this?
Tagged:
  • sujith
    You may have to do Math.floor() of the output and check if the output is the modulus of lot size.
  • thepunisher
    @sujith Thank you. Yes I'll use the floor() function. This is for intraday equity not F&O, so I don't have to worry about the lot size, right?
  • sujith
    There are exceptions, so it is always better to check for lot size. You may not be dealing with that now tomorrow if you happen to stumble upon something that has a lot size something other than 1 then your order will keep getting rejected.
Sign In or Register to comment.