As per our system logs, we have placed below orders at mentioned timestamps. These timestamps are printed after we received order id, that means the orders were sent to kite successfully. Note it carefully that these are market orders so we dont expect delay in execution as these are the most liquid instruments on indian bourses (NF and BNF current month futures).
However, these two orders got executed with 36 secs and 42 secs latency as shown on kite web:
09:30:37 220509300395522 09:30:43 220509300395421
So the question is, if orders were sent to kite at 9:30:01, why would they show up on kite web with timestamp 09:30:37?
We seriously suspect that kite place order API is causing big delays. It returns order id on timely fashion to us, but does not reflect on kite web at the same time. I saw other threads on this, and many users have been complaining this.
In your solution, please do not talk about COLO. We are simply not capable of it. All we expect is, if order id is we received at 9:30:01, they should show up on kite web at the same time. Execution may take 1-2 secs that is acceptable, based on quantity. Why kite web would show that order were sent 9:30:37, that is a very big why.
We inspected your order_id 220509300395522, and it was because of the higher than usual order queue at the today's market start because of market volatility. You can go through this article to know more.
We are observing this issue during times other than the market start also. It's occurring consistently, see below order id and it's log:
placing order for qty: 200 at time 2022-05-23 14:15:05.547956 Order id added to Q at time 2022-05-23 14:15:10.998501. ID is: 220523302112561
The "placing order" is printed before calling place_order API. The "Order id is added to Q" is printed immediately after place_order API returned order id.
This order was not placed during market start, you see it was sent at 14:15:05 and in order book it shows at 14:15:10.
Why this issue occurs during non market start also? I do not think it's exchange capacity issue as mentioned in above article. It seems to be the capacity issue of zerodha's (broker) own order queue.
Can you give satisfactory answer here? We feel quite uncomfortable with this 5 sec delay.
We checked for this order and can see that, it was initiated at 26May2022 13:15:25.201593, with no time delay between order requested to order open pending at exchange. You can check order history for the same.
pprint("received order id from broker at time {0}. ID is: {1}".format(datetime.datetime.now(), order_id))
fyi, pprint is just wrapper overof log.info().
This is the log created:
2022-05-30 12:30:04 INFO placing order for qty: 200 at time 2022-05-30 12:30:04.562541 2022-05-30 12:30:07 DEBUG Starting new HTTPS connection (1): api.kite.trade:443 2022-05-30 12:30:09 DEBUG https://api.kite.trade:443 "POST /orders/regular HTTP/1.1" 200 None 2022-05-30 12:30:10 INFO received order id from broker at time 2022-05-30 12:30:10.486879. ID is: 220530301384263
So you see, call to kite.place_order() was initiated at 12:30:04, we see first DEBUG message from this API at around 12:30:07, this API returned 200 status at 12:30:09 and this is the time shown in order book for order id 220530301384263.
So, does it take 5 sec to finish execution of kite.place_order()?????
Why kite.place_order() takes 5 secs between start placing order and returning 200 status? in normal kite web order this does not occur at all, all calls are placed immediately.
Is it establishing HTTPS connection taking lot of time? Or anything else?
How can we avoid it? For us it's HARD REQUIREMENT that the place_order() is able to place order within 1 sec MAX.
First of all ,we don't provide support for debugging your code.
Maybe, there's some sleep or any other command, network problem delaying your order placement command. You have to fix this yourself.
The only thing I can suggest,remove all your code and just try to place an order. If there's no delay there,it means there is some delaying factor in your code .
Second ,this issue is only happening with you,so it must be some error from your side. If there was a problem with the API,this forum would be flooded with queries about the same.
All other users and I personally see no delay while placing orders. It's as instant as in kite web/app .
@tapanjbhatt, We would like to add that Kite Connect is not suitable for time based / low latency strategies. It is provided for retail use only. For these kind of strategies, it makes sense to co-locate your setup at the exchange premises.
We have not asked for debugging support. Alright, I will exucute this plain 3 lines of code without any other code to place one order and see whether it reproduces or not.
i have explicitly mentioned earlier in this thread not to talk about COLO setup, check my previous comments. We are not HFT traders. One sec latency is not a low latency. It's reasonable to expect not more than 1 sec delay and we are asking only that.
Kindly do not close this thread yet, we will investigate at our end. Meanwhile do you have any pointers which can help us find if there is any network issue?
Are you referring to order_timestamp of the orderbook?
@sujith ,
order type: MARKET
The delay i am observing in the order history, see the image attached:
The order id's were received from kite place order id are taken from the our logs:
09:30:00.412167 220509300395421
09:30:01.063204 220509300395522
So we received order id for both orders around 9:30:00 but order history shows it at 9:30:37 for one order and 9:30:42 for another.
To simplify: kite order history shows one order was placed at 9:30:37, but we received order id at 9:30:00. So where was this order for 37 seconds?
I hope I am able to clarify more now.
Yes, we saw order_timestamp in ON_ORDER_UPDATE is also 'order_timestamp': '2022-05-09 09:30:37' for order id 220509300395522.
But big question is, we have sent order at 9:30:01 and proof of it is we recieved the order_id.
We are observing this issue during times other than the market start also. It's occurring consistently, see below order id and it's log:
placing order for qty: 200 at time 2022-05-23 14:15:05.547956
Order id added to Q at time 2022-05-23 14:15:10.998501. ID is: 220523302112561
The "placing order" is printed before calling place_order API.
The "Order id is added to Q" is printed immediately after place_order API returned order id.
This order was not placed during market start, you see it was sent at 14:15:05 and in order book it shows at 14:15:10.
Why this issue occurs during non market start also? I do not think it's exchange capacity issue as mentioned in above article. It seems to be the capacity issue of zerodha's (broker) own order queue.
Can you give satisfactory answer here? We feel quite uncomfortable with this 5 sec delay.
any update on this?
order id: 220526402241686,
sent from our system at: 13:15:06.535000
order book shows at: 13:15:25
so 19 sec it took to execute.
26May2022 13:15:25.201593
, with no time delay between order requested to order open pending at exchange. You can check order history for the same.We debugged the code and have below findings:
The code is:
pprint('placing order for qty: {0} at time {1}'.format(qty_placed, datetime.datetime.now()))
order_id = kite.place_order(tradingsymbol=trading_symbol,
exchange=kite.EXCHANGE_NFO,
transaction_type= txn_type,
quantity=qty_placed,
variety=kite.VARIETY_REGULAR,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_NRML,
validity=kite.VALIDITY_DAY)
pprint("received order id from broker at time {0}. ID is: {1}".format(datetime.datetime.now(), order_id))
fyi, pprint is just wrapper overof log.info().
This is the log created:
2022-05-30 12:30:04 INFO placing order for qty: 200 at time 2022-05-30 12:30:04.562541
2022-05-30 12:30:07 DEBUG Starting new HTTPS connection (1): api.kite.trade:443
2022-05-30 12:30:09 DEBUG https://api.kite.trade:443 "POST /orders/regular HTTP/1.1" 200 None
2022-05-30 12:30:10 INFO received order id from broker at time 2022-05-30 12:30:10.486879. ID is: 220530301384263
So you see, call to kite.place_order() was initiated at 12:30:04, we see first DEBUG message from this API at around 12:30:07, this API returned 200 status at 12:30:09 and this is the time shown in order book for order id 220530301384263.
So, does it take 5 sec to finish execution of kite.place_order()?????
Why kite.place_order() takes 5 secs between start placing order and returning 200 status? in normal kite web order this does not occur at all, all calls are placed immediately.
Is it establishing HTTPS connection taking lot of time? Or anything else?
How can we avoid it? For us it's HARD REQUIREMENT that the place_order() is able to place order within 1 sec MAX.
Let me know your thoughts.....
Maybe, there's some sleep or any other command, network problem delaying your order placement command. You have to fix this yourself.
The only thing I can suggest,remove all your code and just try to place an order. If there's no delay there,it means there is some delaying factor in your code .
Second ,this issue is only happening with you,so it must be some error from your side. If there was a problem with the API,this forum would be flooded with queries about the same.
All other users and I personally see no delay while placing orders. It's as instant as in kite web/app .
We would like to add that Kite Connect is not suitable for time based / low latency strategies. It is provided for retail use only. For these kind of strategies, it makes sense to co-locate your setup at the exchange premises.
We have not asked for debugging support. Alright, I will exucute this plain 3 lines of code without any other code to place one order and see whether it reproduces or not.
i have explicitly mentioned earlier in this thread not to talk about COLO setup, check my previous comments. We are not HFT traders. One sec latency is not a low latency. It's reasonable to expect not more than 1 sec delay and we are asking only that.
Kindly do not close this thread yet, we will investigate at our end. Meanwhile do you have any pointers which can help us find if there is any network issue?