Basket Order

subha
I am trying to create a basket order programatically to check the margin requirements. But it is always giving zero values though the parameters are correct

url = "https://api.kite.trade/margins/basket"
headers = {
"Authorization": f"token {API_KEY}:{ACCESS_TOKEN}",
"Content-Type": "application/json"
}


basket = [
{
"exchange": "NSE",
"tradingsymbol": "NIFTY2611327000CE",
"transaction_type": "BUY",
"quantity": 65,
"product": "NRML",
"order_type": "LIMIT",
"price":1
}
,
{
"exchange": "NSE",
"tradingsymbol": "NIFTY2611326500CE",
"transaction_type": "SELL",
"quantity": 65,
"product": "NRML",
"order_type": "LIMIT",
"price":2

}
]


response = requests.post(url, json=basket, headers=headers)
print(response.json())
Can you please suggest where it is failing?
  • salim_chisty
    Kindly ensure that the exchange for F&O contracts is set toNFO and check.
  • subha
    Thanks Salim. Code executed with NFO setting. However, the basket order is not listed on the page.
    Any basket order created should be visible on the Zerodha page right?
  • subha
    basket = [
    {
    "exchange": "NFO",
    "tradingsymbol": "NIFTY2611325000PE",
    "transaction_type": "BUY",
    "quantity": 65,
    "product": "NRML",
    "order_type": "MARKET",
    }
    ]
    margin_data = kite.basket_order_margins(basket, consider_positions=False)
    data = margin_data.get("data", {})
    Returns empty data. Can someone let me know what I am missing?
    Goal is to check the margin requirements programatically
  • salim_chisty
    @subha There is currently no direct API available for placing basket orders. We also do not observe any issues with basket order margins; please refer to the Basket Margin API documentation for detailed information on margin calculations.
  • subha
    I don't need to place any basket order. I just want to check the margins.

    basket = [
    { "exchange": "NFO",
    "tradingsymbol": "NIFTY2611325000PE",
    "transaction_type": "BUY",
    "variety": "regular",
    "quantity": 65,
    "product": "NRML",
    "order_type": "MARKET",
    "price":0,
    "trigger_price": 0 }
    ]
    margin_data = kite.basket_order_margins(basket, consider_positions=False)
    data = margin_data.get("data", {})
    I am using the above code. But it returns all zeros. Span and exposure is zero.

    Initial Margin : {'type': '', 'tradingsymbol': '', 'exchange': '', 'span': 0, 'exposure': 0, 'option_premium': 321.75, 'additional': 0, 'bo': 0, 'cash': 0, 'var': 0, 'pnl': {'realised': 0, 'unrealised': 0}, 'leverage': 0, 'charges': {'transaction_tax': 0, 'transaction_tax_type': '', 'exchange_turnover_charge': 0, 'sebi_turnover_charge': 0, 'brokerage': 0, 'stamp_duty': 0, 'gst': {'igst': 0, 'cgst': 0, 'sgst': 0, 'total': 0}, 'total': 0}, 'total': 321.75}
    *******************************************************************
    Final Margin : {'type': '', 'tradingsymbol': '', 'exchange': '', 'span': 0, 'exposure': 0, 'option_premium': 321.75, 'additional': 0, 'bo': 0, 'cash': 0, 'var': 0, 'pnl': {'realised': 0, 'unrealised': 0}, 'leverage': 0, 'charges': {'transaction_tax': 0, 'transaction_tax_type': '', 'exchange_turnover_charge': 0, 'sebi_turnover_charge': 0, 'brokerage': 0, 'stamp_duty': 0, 'gst': {'igst': 0, 'cgst': 0, 'sgst': 0, 'total': 0}, 'total': 0}, 'total': 321.75}
    *******************************************************************
    Margin Type : None
  • subha
    {'initial': {'type': '',
    'tradingsymbol': '',
    'exchange': '',
    'span': 0,
    'exposure': 0,
    'option_premium': 321.75,
    'additional': 0,
    'bo': 0,
    'cash': 0,
    'var': 0,
    'pnl': {'realised': 0, 'unrealised': 0},
    'leverage': 0,
    'charges': {'transaction_tax': 0,
    'transaction_tax_type': '',
    'exchange_turnover_charge': 0,
    'sebi_turnover_charge': 0,
    'brokerage': 0,
    'stamp_duty': 0,
    'gst': {'igst': 0, 'cgst': 0, 'sgst': 0, 'total': 0},
    'total': 0},
    'total': 321.75},
    'final': {'type': '',
    'tradingsymbol': '',
    'exchange': '',
    'span': 0,
    'exposure': 0,
    'option_premium': 321.75,
    'additional': 0,
    'bo': 0,
    'cash': 0,
    'var': 0,
    'pnl': {'realised': 0, 'unrealised': 0},
    'leverage': 0,
    'charges': {'transaction_tax': 0,
    'transaction_tax_type': '',
    'exchange_turnover_charge': 0,
    'sebi_turnover_charge': 0,
    'brokerage': 0,
    'stamp_duty': 0,
    'gst': {'igst': 0, 'cgst': 0, 'sgst': 0, 'total': 0},
    'total': 0},
    'total': 321.75},
    'orders': [{'type': 'equity',
    'tradingsymbol': 'NIFTY2611325000PE',
    'exchange': 'NFO',
    'span': 0,
    'exposure': 0,
    'option_premium': 321.75,
    'additional': 0,
    'bo': 0,
    'cash': 0,
    'var': 0,
    'pnl': {'realised': 0, 'unrealised': 0},
    'leverage': 1,
    'charges': {'transaction_tax': 0,
    'transaction_tax_type': 'stt',
    'exchange_turnover_charge': 0.11431777500000001,
    'sebi_turnover_charge': 0.00032175,
    'brokerage': 20,
    'stamp_duty': 0,
    'gst': {'igst': 3.6206351145, 'cgst': 0, 'sgst': 0, 'total': 3.6206351145},
    'total': 23.735274639500002},
    'total': 321.75}],
    'charges': {'transaction_tax': 0,
    'transaction_tax_type': '',
    'exchange_turnover_charge': 0,
    'sebi_turnover_charge': 0.00032175,
    'brokerage': 20,
    'stamp_duty': 0,
    'gst': {'igst': 0, 'cgst': 0, 'sgst': 0, 'total': 0},
    'total': 0}}

    This is the output I get. The margin api documentation and code is what I have referred to .
    Can you please let me know where the issue could be.
Sign In or Register to comment.