zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
965 stars 462 forks source link

Not able to place order or get order info #174

Closed tandonkunal closed 1 year ago

tandonkunal commented 1 year ago

Not able to place any orders. Getting error. Able to fetch nse data

placeOrder.py

import kiteSettings import logging from kiteconnect import KiteConnect

logging.basicConfig(level=logging.DEBUG)

kite = KiteConnect(api_key="tf69xbrqnwtdv721")

def quoteMethod(symbol): kite = KiteConnect(kiteSettings.api_key) kite.set_access_token(kiteSettings.access_token)

quote_details=kite.quote(symbol)

return quote_details

-----testing ----------------------

symbol='NSE:INFY' details=quoteMethod(symbol) print(details)

details=kite.orders() print(details)

////////////////// ========= RESTART: C:\Users\Admin\Desktop\dirac\module 1\place order.py ======== DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443 DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /quote?i=NSE%3AINFY HTTP/1.1" 200 None {'NSE:INFY': {'instrument_token': 408065, 'timestamp': datetime.datetime(2023, 2, 3, 15, 21, 20), 'last_trade_time': datetime.datetime(2023, 2, 3, 15, 21, 20), 'last_price': 1597.7, 'last_quantity': 274, 'buy_quantity': 185164, 'sell_quantity': 1642861, 'volume': 6810860, 'average_price': 1593.5, 'oi': 0, 'oi_day_high': 0, 'oi_day_low': 0, 'net_change': 0, 'lower_circuit_limit': 1425.4, 'upper_circuit_limit': 1742.1, 'ohlc': {'open': 1597.5, 'high': 1604.65, 'low': 1573, 'close': 1583.75}, 'depth': {'buy': [{'price': 1597.65, 'quantity': 3, 'orders': 2}, {'price': 1597.55, 'quantity': 140, 'orders': 3}, {'price': 1597.5, 'quantity': 21, 'orders': 1}, {'price': 1597.3, 'quantity': 165, 'orders': 2}, {'price': 1597.25, 'quantity': 44, 'orders': 2}], 'sell': [{'price': 1597.7, 'quantity': 294, 'orders': 6}, {'price': 1597.75, 'quantity': 6, 'orders': 3}, {'price': 1597.8, 'quantity': 2863, 'orders': 7}, {'price': 1597.85, 'quantity': 103, 'orders': 3}, {'price': 1597.9, 'quantity': 127, 'orders': 2}]}}} DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443 DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /orders HTTP/1.1" 400 109 Traceback (most recent call last): File "C:\Users\Admin\Desktop\dirac\module 1\place order.py", line 28, in details=kite.orders() File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\kiteconnect\connect.py", line 415, in orders return self._format_response(self._get("orders")) File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\kiteconnect\connect.py", line 851, in _get return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json) File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\kiteconnect\connect.py", line 927, in _request raise exp(data["message"], code=r.status_code) kiteconnect.exceptions.InputException: Invalid api_key or access_token.

/////////////////////////////