Code - for token in option_data: if token in int_token and token in option_buy and token not in tokens_to_remove: if option_data[token] > option_buy[token]: ts = token_symbol_map[token] b_qty = getBuyingQuantity(ts) print(f"Trading symbol : {ts}") print(f"Quantity to buy : {b_qty}")
Response - Trading symbol : MIDCPNIFTY2461412025CE Quantity to buy : 75 Traceback (most recent call last): File "/Users/akashram/PycharmProjects/Zerodha Algo/main.py", line 971, in b_order_id = kite.place_order(tradingsymbol=ts, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 361, in place_order return self._post("order.place", ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 865, in _post return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 937, in _request raise exp(data["message"], code=r.status_code) kiteconnect.exceptions.InputException: The instrument you are placing an order for has either expired or does not exist.
Thanks for the response @sujith, here is the debug logs -
Trading symbol : SENSEX2462177200PE Quantity to buy : 20 DEBUG:kiteconnect.connect:Request: POST https://api.kite.trade/orders/regular {'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'SENSEX2462177200PE', 'transaction_type': 'BUY', 'quantity': 20, 'product': 'NRML', 'order_type': 'MARKET'} {'X-Kite-Version': '3', 'User-Agent': 'Kiteconnect-python/5.0.0', 'Authorization': '----------------'} DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /orders/regular HTTP/1.1" 400 154 DEBUG:kiteconnect.connect:Response: 400 b'{"status":"error","message":"The instrument you are placing an order for has either expired or does not exist.","data":null,"error_type":"InputException"}' Traceback (most recent call last): File "/Users/akashram/PycharmProjects/Zerodha Algo/main.py", line 973, in b_order_id = kite.place_order(tradingsymbol=ts, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 361, in place_order return self._post("order.place", ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 865, in _post return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 937, in _request raise exp(data["message"], code=r.status_code) kiteconnect.exceptions.InputException: The instrument you are placing an order for has either expired or does not exist.
PS: Make sure to remove app and client specific tokens
Trading symbol : SENSEX2462177200PE
Quantity to buy : 20
DEBUG:kiteconnect.connect:Request: POST https://api.kite.trade/orders/regular {'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'SENSEX2462177200PE', 'transaction_type': 'BUY', 'quantity': 20, 'product': 'NRML', 'order_type': 'MARKET'} {'X-Kite-Version': '3', 'User-Agent': 'Kiteconnect-python/5.0.0', 'Authorization': '----------------'}
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /orders/regular HTTP/1.1" 400 154
DEBUG:kiteconnect.connect:Response: 400 b'{"status":"error","message":"The instrument you are placing an order for has either expired or does not exist.","data":null,"error_type":"InputException"}'
Traceback (most recent call last):
File "/Users/akashram/PycharmProjects/Zerodha Algo/main.py", line 973, in
b_order_id = kite.place_order(tradingsymbol=ts,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 361, in place_order
return self._post("order.place",
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 865, in _post
return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 937, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.InputException: The instrument you are placing an order for has either expired or does not exist.