Error when trying to place an order , invalid `api_key` or `access_token`

EVR532
I've done the authentication process and I'm able to print(kite.profile()), print(kite.orders())
But I'm facing this error when I try to place an order, says my api key or access token is invalid:
---------------------------------------------------------------------------
InputException Traceback (most recent call last)
Cell In[18], line 3
1 # Place an order
2 # try:
----> 3 order_id = kite.place_order(
4 variety= "CO", # Order type: Regular, CO, AMO, BO
5 exchange="NSE", # Exchange: NSE, BSE
6 tradingsymbol="SBIN", # Stock Symbol (Example: INFY)
7 transaction_type="BUY", # BUY or SELL
8 quantity=1, # Number of shares
9 order_type="SL", # MARKET, LIMIT, SL, SL-M
10 product="MIS", # CNC (Delivery), MIS (Intraday), NRML
11 validity="DAY", # Order Validity: DAY, IOC
12 price = 714.50,
13 trigger_price=714.0, # Trigger Price
14 )
15 logging.info("Order placed. ID is: {}".format(order_id))
16 # except Exception as e:
17 # logging.info("Order placement failed: {}".format(e))

File d:\KiteTrade\kite\lib\site-packages\kiteconnect\connect.py:361, in KiteConnect.place_order(self, variety, exchange, tradingsymbol, transaction_type, quantity, product, order_type, price, validity, validity_ttl, disclosed_quantity, trigger_price, iceberg_legs, iceberg_quantity, auction_number, tag)
358 if params[k] is None:
359 del (params[k])
--> 361 return self._post("order.place",
362 url_args={"variety": variety},
363 params=params)["order_id"]

File d:\KiteTrade\kite\lib\site-packages\kiteconnect\connect.py:865, in KiteConnect._post(self, route, url_args, params, is_json, query_params)
863 def _post(self, route, url_args=None, params=None, is_json=False, query_params=None):
864 """Alias for sending a POST request."""
--> 865 return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params)

File d:\KiteTrade\kite\lib\site-packages\kiteconnect\connect.py:937, in KiteConnect._request(self, route, method, url_args, params, is_json, query_params)
935 # native Kite errors
936 exp = getattr(ex, data.get("error_type"), ex.GeneralException)
--> 937 raise exp(data["message"], code=r.status_code)
939 return data["data"]
940 elif "csv" in r.headers["content-type"]:

InputException: Invalid `api_key` or `access_token`.
Tagged:
Sign In or Register to comment.