Upstox SDK : How does the cash & balance reflect


I want to understand how does the margin & cash reflect when I place an Intraday order.

Let’s say I have Rs 10,000 as available cash and I place Rs. 9,000 “Intraday” order (not delivery) which usually blocks 20% (Rs. 1,800) of the available cash. How does this reflect in the SDK method response.

Method : get_user_fund_margin

Usual Response:

{'data': {'equity': {'adhoc_margin': 0.0,
                     'available_margin': 0.0,
                     'exposure_margin': 0.0,
                     'notional_cash': 0.0,
                     'payin_amount': 0.0,
                     'span_margin': 0.0,
                     'used_margin': 0.0}},
 'status': 'success'}

Thanks in advance.

Thank you for getting in touch. As per the mentioned scenario, the response will be as follows:

  "status": "success",
  "data": {
    "equity": {
      "used_margin": 1800,
      "payin_amount": 0.0,
      "span_margin": 0.0,
      "adhoc_margin": 0.0,
      "notional_cash": 0.0,
      "available_margin": 8200,
      "exposure_margin": 0.0
1 Like

Thanks for the info @Pradeep_Jaiswar.

So, there is no field that tells me that Rs 7,200 (80% of the transaction of Rs. 9,000) has to be kept reserved if I need to convert it into “Delivery”, and I would need to manage that in the code?

You are correct, unfortunately, there is no field indicating the required reserve amount for conversion to delivery. If your converted-to-delivery trade encounters insufficient funds, it will be declined with a reason of inadequate funds for the conversion.

Got it. Thanks @Pradeep_Jaiswar . I’ll manage it in code then (Y)

Hi @Pradeep_Jaiswar ,

I am little confused on the Margin response variables and wanted your help to understand it better with below example:

Cash At Starting / available_margin	=	Rs. 50,0000

**INTRADAY-1**	=	Rs. 10,000	-->	Rs. 2,000	used_margin    ===> Rs. 2,000
							                available_margin	===> 50,000 - 2,000  ===> 48,000

**INTRADAY-2**	=	Rs. 20,000	-->	Rs. 4,000	used_margin ==> 2000+4000	===>	6,000 (increased)
							available_margin		===>	48,000 - 4,000	===> 44,000

**CNC**	=	Rs. 15,000	-->			used_margin			===>	6,000 (unchanged)
					Rs. 15,000	available_margin		===>	44,000 - 15,000 ==> 29,000

In summary, can I say that used_margin is only incremented/changed in the case of INTRADAY orders… If I do delivery orders, then it has no change?


Hi @RahulMittal87 ,

To answer your queries, here are some pointers

  • What you mentioned is more or less correct. In case of intraday orders, there is a % blocking of amount and in case of CNC/Delivery the user_margin is not affected as we do not do margin specific operations on CNC orders

  • However, I do want to suggest you to not hardcode 20% blocking value in your system as that would be incorrect. Instead, just consume the used_margin field which will be accurate and will account for all the cases
    This is because, exchanges has rules and regulations where they provide minimum margin blocking % for various scrips and the value which is higher (20% or value provided by exchange) is to be chosen mandatorily.

Hope this answers your queries

Great. Thanks for the confirmation @AbhishekRathore . Yep, that 20% was for example; I am using the parameter value to get the right margin. (Y)