I had observed one abnormal behavioral in last few weeks, Market order has been executed using API and response got that Order is Failed. When we checked in KITE application found order actually executed.
Here is one latest example:
IN GET_ORDER_STATUS :: 2019-12-17 15:15:00 NFO BANKNIFTY19DEC32600CE SELL 20 ORDER_FAILED :: NFO BANKNIFTY19DEC32600CE SELL Couldn't find that `order_id`.
@babansfolio, It can happen when Kite trade doesn't receive a response from the OMS. In such cases, you need to catch the exception and check orderbook before you retry placing the order.
@sujith : Is not this weakness of SW in your end ? . order was actually placed but API return errors? Could you please help more to get rid of this kind of problem? Which API calls need to check order book before Retry? Please share order book check syntax.
Kite Connect APIs didn't receive a response from the OMS vendor when you placed an order. Hence it throws an exception.
When a read request times out, you can just directly retry but in case of a write request time out, the system doesn't really know if the write is success or failure. Hence you need to check if it was actually written before you retry. If the write was already successful then it would create a duplicate.
Please share order book check syntax.
You need to check if the order you just placed exists in the orderbook or not. You will have to fetch orderbook and check for the order with the same tradingsymbol, price, trigger price and product.
I am not sure what you are referring to. It is not a specific issue to go fix it. It can happen because of many reasons, it could be the client's connection with Kite trade, Kite trade's cloud connection to OMS data center or OMS overload, or OMS internal sytem connection issue. It could be because of the physical exchange lease lines issue.
@babansfolio There will always be some response issues occasionally in APIs. The way I tackle your issue is by having a tiny delay of 0.5secs, then getting the order book to check if an order with the desired parameters is placed. You can place the commands to do all the above in a function and call it after the order is placed, regardless of if you get an exception or not. I know that this is slightly inefficient, but, it's fool proof.
@sujith In case of a 400-Timed out exception while placing a new order, I will be checking the orderbook for a maximum of 60 seconds to ascertain whether the order actually went through. Since I don't have an order number to check against in the order book, can I reliably use the "tag" parameter that I send in my request parameter to check against? Otherwise I will have to guess since I have no other reference ID, and there might be multiple orders from multiple threads in the orderbook.
Q1] To check the order's current state what can be used? a) Retrieving an order's history or b) Retrieving an order's trades ? (What is the difference between them?)
Q2] Say I have MIS BUY Options contract and now need to sell it. How will I be able to sell the same options contract (Tracking issue)? a) Use fresh "place_order" with same "tradingsymbol" of above contract or else what?? Am a little confused?
Order history is the different states of an order in our system. You can know more here.
Trade is where the buyer and seller actually make the transaction. Once you place an order on the exchange then it can be filled in one trade or multiple trades. Let us say I placed a buy order for 100 quantity it can be executed in one or two or any number of trades. For example, in one trade only 50 can be filled and another 50 in another trade.
If an order is partially filled then the status of the order still remains open. It won't change the order status. You need to either fetch orderbook and check the status of an order or you may fetch order's history.
If you place a buy order for options instrument, once it is executed, even a partial fill will create a position for that instrument, which you can fetch using the positions API. If the net quantity of a position is positive then you have a long position, if it is negative then you have a short position, if it is 0 then you have closed the position. If you have a long position then you need to sell (place a fresh sell order with the same product type) the same quantity to close the position and vice versa for a short position.
[All below is regarding options intraday buying only] I would be tracking the order's status, average_price, filled & pending, cancelled qty by the "order_history" api.
Since I would be calculating the pnl (using charges list + stamp duty calculation) and margins internally; I am not in requirement of "positions API" thus minimize api usage.
(pnl and margins internally:: This way I plan to keep sufficient margins for physical stock trading/invest in parallel through kite web!!. Option's contract strike price would be selected at run time and also I do not want to limit the qty hard coded with approximations-assumptions).
Imp :: Can the profits (hope so) from previous trade be used to buy option for next trade. Does it get added to "net (Net cash balance available for trading)"
Imp :: Can the profits (hope so) from previous trade be used to buy option for next trade. Does it get added to "net (Net cash balance available for trading)"
Yes, you can use the profits from the previous trade for the next trade. However, if you carry the position overnight, there will be a margin penalty by the exchange as the profits from the previous trade are only settled on T+1 day.
Today, I placed an order and at "09:20:01", I got read timeout error, and the order got placed at "09:20:39".
I checked the order history, " PUT ORDER REQ RECEIVED " was at "09:20:39", does this mean Kite received my request at "09:20:39"? If yes, this seems to be a weakness of kite API, not the exchange, I guess.
If this happens, I cannot place another order, and I have no other option but to wait for order to get executed, and price changes every second, this is causing some trouble, as it is happening a lot these days.
OMS means an order management system. There are multiple layers through which order traverses before reaching the OMS and then exchange. It goes through Cloudflare, Kite trade aws, mini-RMS, RMS, OMS, data center, exchange lease lines, and then the exchange. These are just the broad classification. Without looking at the order history, one can't comment. We have seen a scenario where a market order has reached exchange but the order matching happens after several seconds also. Throwing random statements saying the weakness of API and all will not help solve the issue. It needs to be checked, what is happening.
If you received a timeout for the order place request then it means OMS didn't respond to us with the order id when order is placed. You need to fetch orderbook and then retry if you get any kind of error while placing an order. The above scenario is observed from our end, but there can be hundreds of other reasons that can cause this. Your script should be resilient to all these scenarios.
PS: Kite Connect is not for latency-based trading or HFT. If you want to do latency-based trading then you can set up a colo server at the exchange that costs 18lakh/annum upwards. If you are interested, we can help you with that. You can email to kiteconnect(at)zerodha.com
Thank you, It would be good to see this issue resolved If it is in our hands. Please let us know If this issue gets solved or improved in the future. I understand, this issue can happen because of many reasons. Just wanted to bring this issue to the notice of Kite team, so It can be improved in future, If that's in our hand.
If the OMS team is different, should I contact Zerodha support to let them know about this issue?
@KamalChhirang, No need to write to support. We have informed the team to take a look at this.
In the above comment,
I checked the order history, " PUT ORDER REQ RECEIVED " was at "09:20:39", does this mean Kite received my request at "09:20:39"?
it is quite possible that server times don't match. If you receive a timeout while placing an order, you can fetch orderbook and see what happened. You will see an entry in the orderbook with whatever the status order is on.
This ReadTimeOutError is becoming a difficult issue to manage. It is happening daily for first 10 minutes in market and there is no way to manage it as you send an order update as late as 2 minute after placing the initial order. It is clearly a fault at your end / your vendor end, and the right now the user is bearing the brunt.
A simple thing you could do is provide a time guarantee. Say after 30 seconds, if you don't hear back from OMS, you will send a REJECTED message to the user and cancel the order at your end with OMS. With time guarantee user can at least wait for that much time and then replace the order. Here, he is a sitting duck.
If there is an issue please declare to user base, they pay you and deserve to know if the systems are facing issues. It will help them to plan better. Then, if there is a plan of action or a timeline to tackle the issue, please declare it as well.
This ReadTimeOutError is becoming a difficult issue to manage. It is happening daily for first 10 minutes in market
We tried to inspect this for the last 2 days at the market start(09:15-09:25 AM) by placing a couple of EQ Market orders. But, we weren't able to see any delay in the order book update, nor any time-out instances. If you can provide, more info about such orders(like order_id, etc), we will debug further on this.
@rakeshr From last few days, I did not get this error. But today, I got this error in 36 orders (Around 25% of the total orders I placed).
I cannot provide you order_id because I did not get one. Order never got executed.
Please, I request Zerodha Team to fix this as soon as possible or set a specific timeout limit, so we can place another order at least instead of waiting for it to get executed. Also, the orders never got executed this time. Last time, they got executed after 30 seconds or so. This is a bit confusing, should I still wait after 1 hour, will they get executed now?
@KamalChhirang, Kite Connect only place orders, the matching happens at the exchange. It is outside the scope of Kite Connect if your order is not executed. Even a 200 response for order placement means order place request is successful, it doesn't mean the order is executed.
@KamalChhirang, We have informed the team to take a look at this, basically, the behavior you have observed, is you got timeouts but the order is not placed.
If I change it to, 60 seconds, will the API wait for 60 seconds before giving me this error?
I don't think this will solve the issue. It is something else. We have informed the team to take a look at this.
Do you have any suggestions on how should I handle this problem on my side?
I place a MIS order with SL & TR. So total 3 orders.
If the stop loss or target order do not get placed (due to error), what should I do? Should I place the same order again after X seconds (how many seconds), without having the risk of unwanted multiple orders getting placed?
Currently, I am thinking to use CO order, so at least my stoploss order will get placed. But unfortunately, there is no way to set a target order in CO.
@sujith In the Algo deployed; I too get this error frequently - HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7) Can you look into this ?
Just mentioning, If it helps in solving this issue.
I got this timeout error again today in many orders, also got the error while fetching positions. So it is not just related to the order placement system, i guess.
Also, today I got two type of error: One is
Unknown Content-Type (text/html) with response: (b"
Sometimes, after I get this error, the order gets placed and sometimes it do not. It would be great, If I could know, If the order will get placed or not. Or If there is at least a time limit. After the time limit, I can be sure, that the order will not get placed.
I also got these 2 errors on 22 Jul '21 in first few minutes. Sharing detailed stack trace.
1) From kite.place_order() at 22/07/2021 9:20:08 AM.
Had placed 8 different orders, only 1st order succeeded and got below exception after that.
Now if I have to check order book before placing retry orders in case of exceptions, partial order execution is a headache to check what went well what did not. Plus unnecessary brokerage I am paying if I cancel partial orders and attempt all orders again.
What is going wrong here?
File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 421, in _make_request six.raise_from(e, None) File \"\", line 3, in raise_from File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 416, in _make_request httplib_response = conn.getresponse() File \"/usr/lib/python3.8/http/client.py\", line 1344, in getresponse response.begin() File \"/usr/lib/python3.8/http/client.py\", line 307, in begin version, status, reason = self._read_status() File \"/usr/lib/python3.8/http/client.py\", line 268, in _read_status line = str(self.fp.readline(_MAXLINE + 1), \"iso-8859-1\") File \"/usr/lib/python3.8/socket.py\", line 669, in readinto return self._sock.recv_into(b) File \"/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py\", line 326, in recv_into raise timeout(\"The read operation timed out\") socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File \"/usr/lib/python3/dist-packages/requests/adapters.py\", line 439, in send resp = conn.urlopen( File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 719, in urlopen retries = retries.increment( File \"/usr/lib/python3/dist-packages/urllib3/util/retry.py\", line 400, in increment raise six.reraise(type(error), error, _stacktrace) File \"/usr/lib/python3/dist-packages/six.py\", line 703, in reraise raise value File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 665, in urlopen httplib_response = self._make_request( File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 423, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout) File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 330, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
During handling of the above exception, another exception occurred:
order_id = kite.place_order(variety=kite.VARIETY_REGULAR,tradingsymbol=trading_symbol,exchange=\"NFO\",transaction_type=txn_type,quantity=qty,order_type=kite.ORDER_TYPE_MARKET,product=kite.PRODUCT_MIS) File \"/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py\", line 346, in place_order return self._post(\"order.place\", params)[\"order_id\"] File \"/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py\", line 821, in _post return self._request(route, \"POST\", params) File \"/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py\", line 865, in _request raise e File \"/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py\", line 854, in _request r = self.reqsession.request(method, File \"/usr/lib/python3/dist-packages/requests/api.py\", line 60, in request return session.request(method=method, url=url, **kwargs) File \"/usr/lib/python3/dist-packages/requests/sessions.py\", line 533, in request resp = self.send(prep, **send_kwargs) File \"/usr/lib/python3/dist-packages/requests/sessions.py\", line 646, in send r = adapter.send(request, **kwargs) File \"/usr/lib/python3/dist-packages/requests/adapters.py\", line 529, in send raise ReadTimeout(e, request=request) requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
2) From kite.margins() call at 22/07/2021 9:18:10 AM,
File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 421, in _make_request six.raise_from(e, None) File \"<string>\", line 3, in raise_from File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 416, in _make_request httplib_response = conn.getresponse()\n File \"/usr/lib/python3.8/http/client.py\", line 1344, in getresponse response.begin() File \"/usr/lib/python3.8/http/client.py\", line 307, in begin version, status, reason = self._read_status() File \"/usr/lib/python3.8/http/client.py\", line 268, in _read_status line = str(self.fp.readline(_MAXLINE + 1), \"iso-8859-1\") File \"/usr/lib/python3.8/socket.py\", line 669, in readinto return self._sock.recv_into(b) File \"/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py\", line 326, in recv_into raise timeout(\"The read operation timed out\") socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
File \"/usr/lib/python3/dist-packages/requests/adapters.py\", line 439, in send resp = conn.urlopen(\n File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 719, in urlopen retries = retries.increment( File \"/usr/lib/python3/dist-packages/urllib3/util/retry.py\", line 400, in increment\n raise six.reraise(type(error), error, _stacktrace)\n File \"/usr/lib/python3/dist-packages/six.py\", line 703, in reraise raise value File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 665, in urlopen httplib_response = self._make_request( File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 423, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout) File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 330, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
As pointed by other members, almost on a daily basis during 9:15 am to 9:30 am, these issues are happening.
Suggestion: I guess it's time that kite team should do a detailed documentation on exception handling with supporting code to handle these exceptions as these failures are happening from the platform's end. It is unnecessary trouble for developers to learn about new exceptions on a daily basis and write their own retry logic.
Please take this up on very high priority. This is affecting profitability and also causing unnecessary brokerage on top of monthly Kite charges that we are already paying.
Recently API has been very unstable around market open. 9:15 AM to around 9:30 AM. I have started seeing NetworkException while placing orders but the order gets placed. I do check the order book before placing the orders again but do we have some fixed SLA how long to wait before we can consistently say that the order will not be placed by OMS?
Lets say when order placement fails, wait for 15-20 seconds if order is not available in order book, it will not be placed by OMS? Is it possible to provide us users this guarantee? Otherwise we are trading in the dark here and hoping that order doesn't get placed but if it gets placed it creates all sorts of problems with position sizing. Yesterday I doubled my position sizing because order placement failed but I waited 10-15 seconds, verified order book, placed another order but later realized that the original order was successful after some time.
Please Kite, come up with solutions for this problem. Now that due to reduced margins, liquidity is a problem and on top of it you are being so unstable at market hours.
We also got multiple timeouts between 9:15 to 9:30 on 22nd July and 19th July. Kindly don't say its a exchange issue as I am using other brokers as well, I am not getting issue there.
Indeed, I am also facing this issue. It is causing me a considerable amount of loss. I request the Zerodha team to solve this issue with priority. Other brokers are not having this issue.
"Lets say when order placement fails, wait for 15-20 seconds if order is not available in order book, it will not be placed by OMS? Is it possible to provide us users this guarantee? Otherwise we are trading in the dark here and hoping that order doesn't get placed but if it gets placed it creates all sorts of problems with position sizing. Yesterday I doubled my position sizing because order placement failed but I waited 10-15 seconds, verified order book, placed another order but later realized that the original order was successful after some time."
I was going to implement retry logic with order book check, but if this is happening, there is no point. Thank you for saving my time @explorer.
Kite Team - kindly respond with a robust solution / ETA around how to overcome this issue.
I also faced this issue quite few times last month, I would really appreciate, If this issue is fixed as soon as possible. Just mentioning I am happy to pay more for the API, If I dont face this issue again. It is causing losses.
Order timeout during the first few minutes should be fixed, since a couple of days back. You can check and do paste the debug log if it still happening quite frequently.
@KamalChhirang, We just make a call to OMS to place an order, if we get timeout instead of order_id then we won't know if order is placed or not. We also get to know after orderbook is updated.
I got the order timeout error again today after a long time. Giving example of this order:
211006000190343 (order id): At 09:15:45 - I got the order timeout error in my python code. At 09:15:49 PUT ORDER REQ RECEIVED and at 09:15:55 OPEN Pending.
There is a gap of 6 seconds in order getting placed, even after the order request was received.
Another Interesting thing I found is, I use Kite API for 4 accounts. But I only got this error in this account for all my orders. So I assume, this error happened only for orders placed between that 1-2 seconds range in the first minute (09:15).
Mentioning some more order IDs that faced this error:
I Placed few orders at 15:26:01 today, and I got the same error (time out). The put order request was received at 15:26:09 and order was set to "OPEN PENDING" at 15:26:16. Order id is : 211007004875568
This is the first case I found during this time. Can you please bring this to the right team, and I request them to solve it as soon as possible with priority.
We are not doing high frequency trading, but there are two problems here that are very troublesome and decreasing the trade profit probability
1.) Order is getting placed after 15 seconds.
2.) Order feedback gives error (Request timeout instead of order ID). We can somehow maybe find the Order ID using the "tag" feature, but still causing problems.
Thank you.
Edit: Also kite.holdings() seems to be very slow (4-5 seconds) during the first minute (09:15).
@Ravina We checked at our end, there where no order time-out issue. Can you DM your client_id? Issue happened specifically to mentioned order_id(211007004875568), right? We will investigate more on this.
@rakeshr I also faced this issue today @15:20 PM. My concern is not the time out but the actual error code.
you guys are sending 400 code which is reserved for bad requests with invalid params.
Usually for 400, we don't need to check the order book as the error is clearly from our end but in this case, it is a timeout, so the error code should be 500 or above right??
I had the same issue on Oct8 for three consecutive orders placed at 14:59pm: Order request timed out. Please check the order book and confirm before placing again I programmatically check orders in my order book with 1sec delay but didn't find them there too. These kind of glitches can cause issues in automating scripts since orders seem to be going through after a random delay of many secs. Please look into this issue @rakeshr or let us know how to handle it in code.
This problem is occurring almost every day and today was perhaps the worst because SELL orders showed up in order book after a delay of more than 2 mins. This led to my code shorting an option because it assumed previous SELL orders were not placed and caused an unnecessary loss to me.
Here's the change in status of one order that was placed around 14:55 on 14Oct:
'order_id': '211014004750684', 'tradingsymbol': 'NIFTY21O1418050CE', 'transaction_type': 'SELL', 2021-10-14 14:57:22 PUT ORDER REQ RECEIVED 2021-10-14 15:00:08 VALIDATION PENDING 2021-10-14 15:00:10 OPEN PENDING 2021-10-14 15:00:10 OPEN 2021-10-14 15:00:10 OPEN 2021-10-14 15:00:10 OPEN 2021-10-14 15:00:10 COMPLETE
It's taken more than 2 mins to show up as "PUT ORDER REQ RECEIVED" and has stayed in that status for 2.5 mins. I've usually seen that orders go through these status changes in 1sec. It looks like the backend did not take any action for 2.5 mins or is my understanding of the status incorrect?
You are not being responsive towards these critical issues and you are neither providing us with a clear path forward nor acknowledging issues in your systems. Please let us know if some accounts are being throttled for some reason or if your system cannot handle the load on option expiry days or late afternoons.
Today, I got this error on 90% of my orders during the first minute, I tried placing 30-40 orders on 4 accounts, I was unable to see my holdings, positions on Kite web, nor place orders with success.
This error is getting worse day by day, please improve it with high priority.
I have also got this error today on both during that day start as well as the day-end .Kindly support how to resolve this , at 09:18 requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7) at 03:18requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
Hey guys! I am planning to use 'Tags' while placing an order so that even if order has failed, system checks for open orders/completed orders and we can cross reference them before placing a new order.
It can happen when Kite trade doesn't receive a response from the OMS. In such cases, you need to catch the exception and check orderbook before you retry placing the order.
Could you please help more to get rid of this kind of problem?
Which API calls need to check order book before Retry?
Please share order book check syntax.
When a read request times out, you can just directly retry but in case of a write request time out, the system doesn't really know if the write is success or failure. Hence you need to check if it was actually written before you retry. If the write was already successful then it would create a duplicate. You need to check if the order you just placed exists in the orderbook or not. You will have to fetch orderbook and check for the order with the same tradingsymbol, price, trigger price and product.
About Order Book check, are you suggest to use following?
"Retrieving all trades"
"Retrieving an order's trades"
About
Since I don't have an order number to check against in the order book, can I reliably use the "tag" parameter that I send in my request parameter to check against? Otherwise I will have to guess since I have no other reference ID, and there might be multiple orders from multiple threads in the orderbook.
Q1] To check the order's current state what can be used?
a) Retrieving an order's history or
b) Retrieving an order's trades ?
(What is the difference between them?)
Q2] Say I have MIS BUY Options contract and now need to sell it. How will I be able to sell the same options contract (Tracking issue)?
a) Use fresh "place_order" with same "tradingsymbol" of above contract or else what?? Am a little confused?
Trade is where the buyer and seller actually make the transaction. Once you place an order on the exchange then it can be filled in one trade or multiple trades. Let us say I placed a buy order for 100 quantity it can be executed in one or two or any number of trades. For example, in one trade only 50 can be filled and another 50 in another trade.
If an order is partially filled then the status of the order still remains open. It won't change the order status.
You need to either fetch orderbook and check the status of an order or you may fetch order's history.
If you place a buy order for options instrument, once it is executed, even a partial fill will create a position for that instrument, which you can fetch using the positions API. If the net quantity of a position is positive then you have a long position, if it is negative then you have a short position, if it is 0 then you have closed the position.
If you have a long position then you need to sell (place a fresh sell order with the same product type) the same quantity to close the position and vice versa for a short position.
I would be tracking the order's status, average_price, filled & pending, cancelled qty by the "order_history" api.
Since I would be calculating the pnl (using charges list + stamp duty calculation) and margins internally; I am not in requirement of "positions API" thus minimize api usage.
(pnl and margins internally:: This way I plan to keep sufficient margins for physical stock trading/invest in parallel through kite web!!. Option's contract strike price would be selected at run time and also I do not want to limit the qty hard coded with approximations-assumptions).
Imp :: Can the profits (hope so) from previous trade be used to buy option for next trade. Does it get added to "net (Net cash balance available for trading)"
Your opinion is most desirable.
What do you mean by "OMS"?
Today, I placed an order and at "09:20:01", I got read timeout error, and the order got placed at "09:20:39".
I checked the order history, " PUT ORDER REQ RECEIVED " was at "09:20:39", does this mean Kite received my request at "09:20:39"? If yes, this seems to be a weakness of kite API, not the exchange, I guess.
If this happens, I cannot place another order, and I have no other option but to wait for order to get executed, and price changes every second, this is causing some trouble, as it is happening a lot these days.
Without looking at the order history, one can't comment. We have seen a scenario where a market order has reached exchange but the order matching happens after several seconds also.
Throwing random statements saying the weakness of API and all will not help solve the issue. It needs to be checked, what is happening.
If you received a timeout for the order place request then it means OMS didn't respond to us with the order id when order is placed. You need to fetch orderbook and then retry if you get any kind of error while placing an order. The above scenario is observed from our end, but there can be hundreds of other reasons that can cause this. Your script should be resilient to all these scenarios.
PS: Kite Connect is not for latency-based trading or HFT. If you want to do latency-based trading then you can set up a colo server at the exchange that costs 18lakh/annum upwards. If you are interested, we can help you with that. You can email to kiteconnect(at)zerodha.com
{"message":"No response from server with error code: ECONNABORTED","error_type":"NetworkException","data":null}
If the OMS team is different, should I contact Zerodha support to let them know about this issue?
Thanks again for the clarification.
No need to write to support. We have informed the team to take a look at this.
In the above comment, it is quite possible that server times don't match. If you receive a timeout while placing an order, you can fetch orderbook and see what happened. You will see an entry in the orderbook with whatever the status order is on.
This ReadTimeOutError is becoming a difficult issue to manage. It is happening daily for first 10 minutes in market and there is no way to manage it as you send an order update as late as 2 minute after placing the initial order. It is clearly a fault at your end / your vendor end, and the right now the user is bearing the brunt.
A simple thing you could do is provide a time guarantee. Say after 30 seconds, if you don't hear back from OMS, you will send a REJECTED message to the user and cancel the order at your end with OMS. With time guarantee user can at least wait for that much time and then replace the order. Here, he is a sitting duck.
If there is an issue please declare to user base, they pay you and deserve to know if the systems are facing issues. It will help them to plan better. Then, if there is a plan of action or a timeline to tackle the issue, please declare it as well.
If you can provide, more info about such orders(like order_id, etc), we will debug further on this.
I cannot provide you order_id because I did not get one. Order never got executed.
Please, I request Zerodha Team to fix this as soon as possible or set a specific timeout limit, so we can place another order at least instead of waiting for it to get executed. Also, the orders never got executed this time. Last time, they got executed after 30 seconds or so. This is a bit confusing, should I still wait after 1 hour, will they get executed now?
Kite Connect only place orders, the matching happens at the exchange. It is outside the scope of Kite Connect if your order is not executed.
Even a 200 response for order placement means order place request is successful, it doesn't mean the order is executed.
So, I called and got error (Exception caught it, it was timeout error).
Now, I don't know order id, the order do not show in the order book.
Last time, it happened. I got timeout error but order got placed after 30 seconds, this time, none of my orders got placed.
I got the timeout error in 36 orders today, that I placed via python API in few of my accounts.
_default_timeout = 7 # In seconds
If I change it to, 60 seconds, will the API wait for 60 seconds before giving me this error?
We have informed the team to take a look at this, basically, the behavior you have observed, is you got timeouts but the order is not placed. I don't think this will solve the issue. It is something else. We have informed the team to take a look at this.
Do you have any suggestions on how should I handle this problem on my side?
I place a MIS order with SL & TR. So total 3 orders.
If the stop loss or target order do not get placed (due to error), what should I do? Should I place the same order again after X seconds (how many seconds), without having the risk of unwanted multiple orders getting placed?
Currently, I am thinking to use CO order, so at least my stoploss order will get placed. But unfortunately, there is no way to set a target order in CO.
HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
Can you look into this ?
kite.positions()
kite.holdings()
Please forward this detail also to the developers, as it may help.
I got this timeout error again today in many orders, also got the error while fetching positions. So it is not just related to the order placement system, i guess.
Also, today I got two type of error: One is and the other one is:
Sometimes, after I get this error, the order gets placed and sometimes it do not. It would be great, If I could know, If the order will get placed or not. Or If there is at least a time limit. After the time limit, I can be sure, that the order will not get placed.
1) From kite.place_order() at 22/07/2021 9:20:08 AM.
Had placed 8 different orders, only 1st order succeeded and got below exception after that.
Now if I have to check order book before placing retry orders in case of exceptions, partial order execution is a headache to check what went well what did not. Plus unnecessary brokerage I am paying if I cancel partial orders and attempt all orders again.
What is going wrong here?
Suggestion: I guess it's time that kite team should do a detailed documentation on exception handling with supporting code to handle these exceptions as these failures are happening from the platform's end. It is unnecessary trouble for developers to learn about new exceptions on a daily basis and write their own retry logic.
Please take this up on very high priority. This is affecting profitability and also causing unnecessary brokerage on top of monthly Kite charges that we are already paying.
This documentation hardly has any info: https://kite.trade/docs/connect/v3/exceptions/
Thanks.
Lets say when order placement fails, wait for 15-20 seconds if order is not available in order book, it will not be placed by OMS? Is it possible to provide us users this guarantee? Otherwise we are trading in the dark here and hoping that order doesn't get placed but if it gets placed it creates all sorts of problems with position sizing. Yesterday I doubled my position sizing because order placement failed but I waited 10-15 seconds, verified order book, placed another order but later realized that the original order was successful after some time.
Please Kite, come up with solutions for this problem. Now that due to reduced margins, liquidity is a problem and on top of it you are being so unstable at market hours.
I was going to implement retry logic with order book check, but if this is happening, there is no point. Thank you for saving my time @explorer.
Kite Team - kindly respond with a robust solution / ETA around how to overcome this issue.
Can I request Zerodha/Kite team to implement a "maximum time" for the timeout issue, In case it happens again rarely?
So after waiting for X seconds, we can be assured, the order wont get placed and we place the order again.
Thank you
We just make a call to OMS to place an order, if we get timeout instead of order_id then we won't know if order is placed or not.
We also get to know after orderbook is updated.
Sorry, I confuse Kite API & Kite platform team sometimes. Thanks
211006000190343 (order id): At 09:15:45 - I got the order timeout error in my python code. At 09:15:49 PUT ORDER REQ RECEIVED and at 09:15:55 OPEN Pending.
There is a gap of 6 seconds in order getting placed, even after the order request was received.
Another Interesting thing I found is, I use Kite API for 4 accounts. But I only got this error in this account for all my orders. So I assume, this error happened only for orders placed between that 1-2 seconds range in the first minute (09:15).
Mentioning some more order IDs that faced this error:
211006000190377, 211006000190333, 211006000190341, 211006000190369, 211006000190367, 211006000190370.
I request, please bring this up to the OMS and please update me, if possible.
I assume at 09:15 the activity is at very high, and one of the layer (Kite, OMS, Exchange) is unable to handle this very high activity sometimes.
Thank you.
I Placed few orders at 15:26:01 today, and I got the same error (time out). The put order request was received at 15:26:09 and order was set to "OPEN PENDING" at 15:26:16. Order id is : 211007004875568
This is the first case I found during this time. Can you please bring this to the right team, and I request them to solve it as soon as possible with priority.
We are not doing high frequency trading, but there are two problems here that are very troublesome and decreasing the trade profit probability
1.) Order is getting placed after 15 seconds.
2.) Order feedback gives error (Request timeout instead of order ID). We can somehow maybe find the Order ID using the "tag" feature, but still causing problems.
Thank you.
Edit: Also kite.holdings() seems to be very slow (4-5 seconds) during the first minute (09:15).
We checked at our end, there where no order time-out issue. Can you DM your client_id?
Issue happened specifically to mentioned order_id(
211007004875568
), right?We will investigate more on this.
you guys are sending 400 code which is reserved for bad requests with invalid params.
Usually for 400, we don't need to check the order book as the error is clearly from our end but in this case, it is a timeout, so the error code should be 500 or above right??
Order request timed out. Please check the order book and confirm before placing again
I programmatically check orders in my order book with 1sec delay but didn't find them there too. These kind of glitches can cause issues in automating scripts since orders seem to be going through after a random delay of many secs.
Please look into this issue @rakeshr or let us know how to handle it in code.
This problem is occurring almost every day and today was perhaps the worst because SELL orders showed up in order book after a delay of more than 2 mins. This led to my code shorting an option because it assumed previous SELL orders were not placed and caused an unnecessary loss to me.
Here's the change in status of one order that was placed around 14:55 on 14Oct: It's taken more than 2 mins to show up as "PUT ORDER REQ RECEIVED" and has stayed in that status for 2.5 mins. I've usually seen that orders go through these status changes in 1sec. It looks like the backend did not take any action for 2.5 mins or is my understanding of the status incorrect?
You are not being responsive towards these critical issues and you are neither providing us with a clear path forward nor acknowledging issues in your systems. Please let us know if some accounts are being throttled for some reason or if your system cannot handle the load on option expiry days or late afternoons.
This error is getting worse day by day, please improve it with high priority.
at 09:18 requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
at 03:18requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)