Errors

suraj
Hi,

I have developed an automated trading system using kitepyconnect and I am facing too many problems with the API.

Errors that I recieved.
1. While requesting for open orders/position/modifying orders.
sometimes when I make any one of above requests my code ends up giving an error saying 'Gateway timed out'. Is this related to internet connection? There's no way that my code can loose internet connection because I run my codes in a linux server which has 24/7 internet connection.

2. When open orders request is made
Sometimes When my code requests for open orders it ends up giving an error saying 'Invalid response format'. When and why will this error come? and how can I overcome this?

Errors which I didn't receive.

Since the product we are developing is an automated trading system we need to make sure that every order we place is accepted by zerodha. Sometimes zerodha may reject the order we place because of reasons like less margin,Invalid quantity/price etc.. We need to inform such things to our clients in an automated way like sending automatic e-mails or sms.

1. We tried to place orders with invalid quantity/price/inavlid order type our codes ended up giving errors like 'invalid quantity'/Inavlid order type.

2. We placed a higher quantity order when we had a very less margin. Order got rejected and API didn't send any errors or exception. It should have sent an exception. Later when we logged into kite and checked the order status was rejected with a rejection reason saying '
kiteconnect.exceptions.DataException: Invalid response format'. Why didn't my code recieve the same rejection reason? Do I have to look somewhere else for such rejection messages?

3. At 09:42IST today I placed a buy order on instrument NIFTY16JUN8200CE. The order got rejected and the API didn't send any exception or error message. Later when I logged into kite I got to know the order is been rejected and the rejection reason was like 'error user/user_target not logged in'. I really don't know why did it happen. I thought it may be is because of access/request token. After sometime I ran the same piece of code with the same access token I used earlier and zerodha accepted my order. Why when will such error come? How can I overcome it?
  • Kailash
    Hi @suraj
    1) "Gateway timed out" means your Python client was not able to connect to our API server. It could've been a DNS issue, a network issue, or downtime at our end. The APIs are distributed across 2 different data centres, and there has been no logged or reported downtime.

    2) "Invalid response format" -- Are you sure you're running the latest Python client? Please update to the latest version, 2.9

    ----------------------------

    1) That's correct. Invalid parameters may give you an immediate response.

    2) Margin related rejections cannot be a part of the order placement API. All the API does is validate the parameters and place it and return the order ID. What happens to the order (which may depend on numerous factors including market conditions) is a different affair. You should use the Postback (Webook) APIs to receive realtime updates to orders, including completion, cancellation, rejection.

    3) The tokens are flushed every morning. It sounds like your token managed to persist somehow. Will look into this.
Sign In or Register to comment.