kite.place_order giving an exception

mjhaveri001
order_id = kite.place_order(exchange=kite.EXCHANGE_NSE, transaction_type=kite.TRANSACTION_TYPE_SELL, quantity=1,
product='MIS', order_type='SL-M', validity='DAY', trigger_price='600', variety='REGULAR', tradingsymbol='JUSTDIAL')


Is giving me an input exception saying that "api_key" or "access_token" are invalid but I'm very confident that this is not the case as kite.order(), kite.instruments() and other methods are working okay. Can somebody help!!

Thanks
  • sujith
    Can you run it in debug mode and paste the complete logs here?
  • mjhaveri001
    mjhaveri001 edited January 23
    Gotchu here are the logs:


    Traceback (most recent call last):
    File "place_order.py", line 10, in <module>
    order_id = kite.place_order(exchange=kite.EXCHANGE_NSE, transaction_type=kite.TRANSACTION_TYPE_SELL,
    quantity=1, product='MIS', order_type='SL-M', validity='DAY', trigger_price='600', variety='REGULAR',
    tradingsymbol='JUSTDIAL')
    File "/Users/mahirjhaveri/Code/auto-trade/venv/lib/python3.7/site-packages/kiteconnect-3.8.1-
    py3.7.egg/kiteconnect/connect.py", line 346, in place_order
    File "/Users/mahirjhaveri/Code/auto-trade/venv/lib/python3.7/site-packages/kiteconnect-3.8.1-
    py3.7.egg/kiteconnect/connect.py", line 821, in _post
    File "/Users/mahirjhaveri/Code/auto-trade/venv/lib/python3.7/site-packages/kiteconnect-3.8.1-
    py3.7.egg/kiteconnect/connect.py", line 886, in _request
    kiteconnect.exceptions.InputException: Invalid `api_key` or `access_token`.


    Lemme know if you need any more logs/details. Thanks
  • sujith
    It seems like you are sending an invalid api_key or access_token. Are you sure you are sending a valid auth header?
    You can run pykiteconnect with debug flag true.
  • sujith
    sujith edited January 23
    And the variety is regular and not REGULAR
  • mjhaveri001
    Changing variety from 'REGULAR' to 'regular' did the job. I guess there was an issue with the exceptions as it told me invalid api_key/access_token when the real problem was the parameter I had passed.
    Thanks
Sign In or Register to comment.