It looks like you're new here. If you want to get involved, click one of these buttons!
kiteconnect.exceptions.InputException: invalid json
kite.order_margins({'order_id':XXXXX,'exchange':'NFO', 'tradingsymbol':'XXXXXXXX','transaction_type':'SELL','variety':'regular','product':'MIS','order_type':'MARKET','quantity':75,'price':0,'trigger_price':0})
I am able to get the margin info. However the margin of all live trades aren't summing upto the total used margin!
KiteConnect.order_margins() got an unexpected keyword argument 'exchange'
this is server-side code
@socketio.on('send_required_margin')
def send_required_margin(data):
print(data)
try:
margin_data = kite.order_margins(
exchange = 'NFO',
tradingsymbol = data.get('tradingsymbol'),
transaction_type = data.get('transaction_type'),
variety = data.get('variety'),
product = data.get('product'),
order_type = data.get('order_type'),
quantity = data.get('quantity'),
price = data.get('price'),
trigger_price = data.get('trigger_price')
)
# Emitting response back to client
socketio.emit('margin_response', {'success': True, 'margin_data': margin_data})
except Exception as e:
print(e)
socketio.emit('margin_response', {'success': False, 'message': str(e)})
this is frontend js
socket.emit('send_required_margin', {
tradingsymbol: symbol,
transaction_type: transactionType,
variety: 'regular',
product: 'NRML',
order_type: 'LIMIT',
quantity: quantity,
price: price,
trigger_price: null
});
You can also check out the example here.
The final margin displays the eventual margin that will be blocked in the Zerodha account after the order execution considering the hedge benefits.