Order Margins API - Leverage Information Not Appearing

Manideep
When calling the `orderMargins` API endpoint, the response doesn't include leverage information, despite using the recommended parameters.

## Environment Details
- Kite Connect Version: 5.0.1
- Testing during market hours: NO

const order = {
"exchange": "NSE",
"tradingsymbol": "JINDALSAW",
"transaction_type": "BUY",
"variety": "regular",
"product": "MIS",
"order_type": "MARKET",
"quantity": 1000,
"trigger_price": 0,
"squareoff": 0,
"stoploss": 0,
"trailing_stoploss": 0
};
const margins = await kiteConnect.orderMargins([order]);

## Current Response

[
{
type: 'equity',
tradingsymbol: 'JINDALSAW',
exchange: 'NSE',
charges: {
transaction_tax: 0,
transaction_tax_type: 'stt',
exchange_turnover_charge: 0.009492440000000001,
sebi_turnover_charge: 0.0003092,
brokerage: 0.09276,
stamp_duty: 0,
gst: [Object],
total: 0.1210227352
},
total: 61.84
}
]

## Questions
1. Are there additional parameters needed to receive leverage details in the response?
2. Is this information only available for certain instruments or during specific market hours?

Any guidance would be appreciated. Thank you!
  • sujith
    It seems fine at our end. A param can't go missing from the response. It might show full leverage but can't go missing. You can know more about the response parameters here.
  • sujith
    You may enable debug logs of the Kite Connect client library and check the logs.
  • Manideep
    javascript:backend/controllers/kiteController.js
    async getOrderMargins(req, res) {
    try {
    const orders = [{
    exchange: "NSE",
    tradingsymbol: "INFY",
    transaction_type: "BUY",
    variety: "regular",
    product: "CNC",
    order_type: "MARKET",
    quantity: 1,
    price: 0,
    trigger_price: 0
    }];
    const response = await kiteService.getOrderMargins(orders);
    console.log('Complete Response:', JSON.stringify(response, null, 2));
    res.json(response);
    } catch (error) {
    console.error('Error getting order margins:', error);
    res.status(500).json({
    error: 'Failed to fetch order margins',
    details: error.message
    });
    }
    }


    ## Service Code

    javascript:backend/services/kiteService.js
    async getOrderMargins(orders) {
    try {
    const response = await this.kiteConnect.orderMargins(orders);
    console.log('Full API Response:', JSON.stringify(response, null, 2));
    return response;
    } catch (err) {
    console.error('Error getting order margins:', {
    message: err.message,
    stack: err.stack,
    response: err.response?.data
    });
    throw err;
    }
    }

    // Raw Response Object
    {
    data: {
    status: 'success',
    data: [ [Object] ]
    }
    }

    // Actual Data when Logged
    [
    {
    "type": "equity",
    "tradingsymbol": "INFY",
    "exchange": "NSE",
    "charges": {
    "transaction_tax": 1.9788,
    "transaction_tax_type": "stt",
    "exchange_turnover_charge": 0.06074916,
    "sebi_turnover_charge": 0.0019787999999999997,
    "brokerage": 0,
    "stamp_duty": 0,
    "gst": {
    "igst": 0.0112910328,
    "cgst": 0,
    "sgst": 0,
    "total": 0.0112910328
    },
    "total": 2.0528189928
    },
    "total": 1978.8
    }
    ]


    ## Questions
    1. Is this response structure correct? The raw response shows nested data objects but the logged data is different.
    3. Is the `mode=compact` parameter affecting the response structure?

    Any guidance would be appreciated. Thank you!
  • sujith
    You can enable debug logs while initializing Kite Connect object. You can refer to the code here.
Sign In or Register to comment.