While closing the open positions through api, its sometimes treated as seperate sell orders .
Hi @karun.jiju-vzg ,
Make sure you are placing market order.
let’s say you have open position of ITC and you are long for ITC
And now you want to close this position. So you placed one sell order through fyers APIs.
And when you are giving parameter, you are placing as a market order. if you place limit order then it will go to Queue and wait to hit the order at that time.
Hope it will help you. Thanks
Our buy and sell orders are both in market order.. Still this is happening..
Order book : {
'clientId': '',
'id': '23081000096588',
'exchOrdId': '1400000021367401',
'qty': 15,
'remainingQuantity': 0,
'filledQty': 15,
'discloseQty': 0,
'limitPrice': 312.65,
'stopPrice': 0,
'tradedPrice': 312.65,
'type': 2,
'fyToken': '101123081739037',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381744900CE',
'instrument': 14,
'message': '',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:05:26',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': 1,
'status': 2,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 44900 CE',
'ch': -115.45,
'chp': -36.46,
'lp': 201.2,
'slNo': 1,
'dqQtyRem': 0,
'orderNumStatus': '23081000096588:2',
'disclosedQty': 0
}, {
'clientId': '',
'id': '23081000134088',
'exchOrdId': '',
'qty': 30,
'remainingQuantity': 0,
'filledQty': 0,
'discloseQty': 0,
'limitPrice': 0,
'stopPrice': 0,
'tradedPrice': 0,
'type': 2,
'fyToken': '101123081739037',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381744900CE',
'instrument': 14,
'message': 'RED:Margin Shortfall:INR 77,562.15 Available:INR 21,808.49 for C-XC09002 [FYERS_RISK_CUG]',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:23:07',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': -1,
'status': 5,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 44900 CE',
'ch': -115.45,
'chp': -36.46,
'lp': 201.2,
'slNo': 2,
'dqQtyRem': 0,
'orderNumStatus': '23081000134088:5',
'disclosedQty': 0
}, {
'clientId': '',
'id': '23081000159504',
'exchOrdId': '1400000034049567',
'qty': 30,
'remainingQuantity': 0,
'filledQty': 30,
'discloseQty': 0,
'limitPrice': 503.25,
'stopPrice': 0,
'tradedPrice': 503.25,
'type': 2,
'fyToken': '101123081739040',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381745000PE',
'instrument': 14,
'message': '',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:30:31',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': 1,
'status': 2,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 45000 PE',
'ch': 103.25,
'chp': 30.25,
'lp': 444.6,
'slNo': 3,
'dqQtyRem': 0,
'orderNumStatus': '23081000159504:2',
'disclosedQty': 0
}, {
'clientId': '',
'id': '23081000174643',
'exchOrdId': '1400000037007728',
'qty': 15,
'remainingQuantity': 0,
'filledQty': 15,
'discloseQty': 0,
'limitPrice': 560.45,
'stopPrice': 0,
'tradedPrice': 560.45,
'type': 2,
'fyToken': '101123081739040',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381745000PE',
'instrument': 14,
'message': '',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:35:34',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': -1,
'status': 2,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 45000 PE',
'ch': 103.25,
'chp': 30.25,
'lp': 444.6,
'slNo': 4,
'dqQtyRem': 0,
'orderNumStatus': '23081000174643:2',
'disclosedQty': 0
}, {
'clientId': '',
'id': '23081000185710',
'exchOrdId': '1400000039972454',
'qty': 15,
'remainingQuantity': 0,
'filledQty': 15,
'discloseQty': 0,
'limitPrice': 530.7,
'stopPrice': 0,
'tradedPrice': 530.7,
'type': 2,
'fyToken': '101123081739040',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381745000PE',
'instrument': 14,
'message': '',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:40:51',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': -1,
'status': 2,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 45000 PE',
'ch': 103.25,
'chp': 30.25,
'lp': 444.6,
'slNo': 5,
'dqQtyRem': 0,
'orderNumStatus': '23081000185710:2',
'disclosedQty': 0
}, {
'clientId': '',
'id': '23081000185727',
'exchOrdId': '',
'qty': 15,
'remainingQuantity': 0,
'filledQty': 0,
'discloseQty': 0,
'limitPrice': 0,
'stopPrice': 0,
'tradedPrice': 0,
'type': 2,
'fyToken': '101123081739040',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381745000PE',
'instrument': 14,
'message': 'RED:Margin Shortfall:INR 77,145.98 Available:INR 21,808.49 for C-XC09002 [FYERS_RISK_CUG]',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:40:51',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': -1,
'status': 5,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 45000 PE',
'ch': 103.25,
'chp': 30.25,
'lp': 444.6,
'slNo': 6,
'dqQtyRem': 0,
'orderNumStatus': '23081000185727:5',
'disclosedQty': 0
}, {
'clientId': '',
'id': '23081000185735',
'exchOrdId': '1400000039976077',
'qty': 15,
'remainingQuantity': 0,
'filledQty': 15,
'discloseQty': 0,
'limitPrice': 184.55,
'stopPrice': 0,
'tradedPrice': 184.55,
'type': 2,
'fyToken': '101123081739037',
'exchange': 10,
'segment': 11,
'symbol': 'NSE:BANKNIFTY2381744900CE',
'instrument': 14,
'message': '',
'offlineOrder': False,
'orderDateTime': '10-Aug-2023 10:40:52',
'orderValidity': 'DAY',
'pan': '',
'productType': 'MARGIN',
'side': -1,
'status': 2,
'source': 'API',
'ex_sym': 'BANKNIFTY',
'description': '23 Aug 17 44900 CE',
'ch': -115.45,
'chp': -36.46,
'lp': 201.2,
'slNo': 7,
'dqQtyRem': 0,
'orderNumStatus': '23081000185735:2',
'disclosedQty': 0
}
hi @karun.jiju-vzg
Can you show me how it is creating like how it possible for one client you are long on one position and then short as well for same position. and it is showing in your position.
I have the order book json posted. Hope you understand from that.. See the sell order there.. Its after the buy order but saying margin short fall. Instead it should close the current position.
Hi @karun.jiju-vzg
As I can see all are okay situations, By mistake you give wrong parameter
Again check first very u bought 44900 CE 15 QTY
But in second order u try to sell 30 qty that
So you got margin fall
then again you will go down same mistake again you did.
That’s why you got the errors (Margin fall)
You again check your order book.
Hope it will help
thank you