Hi All,
Few days back I noticed few threads on Twitter (now X) about speed of order execution and API response times of various Stock Trading platforms.
I also tweeted a video about Order Execution speeds on Dhan where I mentioned that we now execute 90% of all orders placed on Dhan below 50 ms; this post is an extension to the same and an attempt at a simpler explanation how things work behind the scenes for order execution on Stock Trading platforms. My views and notes about Dhan here are backed by data, and being a related party Iâm sure readers will take my views outside of Dhan with a pinch of salt
Firstly, it is important to understand and know that it is practically very difficult to benchmark performance of order execution APIs. The reasons could be many, I will list a simple reason - for everything being the same, it is not possible to replicate the same demand/supply, bids/ask and liquidity on exchange for all APIs if they were to be tested at once, or even to replicate the same demand and liquidity conditions on exchanges for testing the performance individually.
Outside of this, the following factors determine the response times and execution speeds of a stock trading platform
- Underlying OMS (Order Management System) used by the Stock Broker
- Underlying Network and Technology Infrastructure
- Connectivity & Bandwidth of direct connections between Exchanges and the Brokerâs Trading systems
- Integrations with Front End systems (Mobile App, Websites or via APIs)
- Multiple Check and Validations in place (beyond the ones directly handled by Order & Risk Management Systems)
- APIs: Directly linked to the OMS or via an API Wrapper
- Self-Managed Technology via Dedicated Infrastructure v/s Managed Infrastructure via Third Party Vendors
- and more factorsâŚ
Beyond this, there are other factors that will also determine speed of execution:
- Available liquidity on the exchange at that time (bids and asks)
- Queuing of Orders at Broker end - do they have multiple instances of Order Management Systems running at same time
- Queuing of Orders at Infra end - does broker have multiple direct connections to exchanges + utilisation of orders / bandwidth at that time.
Most stock trading platforms in India use third-party Order Management Systems (OMS); which essentially means that the expected speeds of Order Execution across these brokers with same OMS will more or less have the same performance.
Tell more about Dhanâs Technology Stack
Let me start with this post, few months back I wrote a detailed post about us scaling up our Technology Stack, Network and Infrastructure which you can read here - Dhan: Update on scaling up our Technology Stack, Network and Infrastructure
Here are some of the important aspects about Dhan with respect to Order Execution and Performance:
- Dhan has built its own in-house trading system on the latest technology stack that we now internally call DEXTS (Dhan Exchange Trading System).
- Dhan is one of the very few Stock Trading platforms that owns and manages its entire technology infrastructure including core trading systems.
- 100% of all Exchange Orders on Dhan go through our own trading system - DEXTS
- This gives us flexibility to build, iterate and scale faster - let me demonstrate this with details below.
What is the performance of Dhan (DEXT) on how has it improved?
As of today (May 2024), Dhanâs trading system DEXT processes > 85% of all trades in under 25 ms (yes - under 25 milli seconds). This is about 4 to 5 times faster than the typical industry averages of 80-120 ms.
How did we get to these execution speeds - in the same post (Dhan: Update on scaling up our Technology Stack, Network and Infrastructure), I mentioned that Dhan (in December 2023) was processing 80% of our trades in under 100 ms and more than 50% of these we did under 50ms⌠this has now improved dramatically!
We deployed some changes in January earlier this year on DEXTS, and this is how our performance looked in February 2024.
DEXT Performance in Feb 2024:
Note: While we moved to DEXT in November 2022, it took us while to have continued optimisation of performance. Here we benchmarked with the usual industry average of 80ms - 100ms that we had earlier optimised in December 2023.
DEXT Performance in March 2024:
We continued with our performance optimisations on DEXT, and further were able to speed of order execution as below for March 2024:
By end of March 2024, we were able to achieve 3X faster processing times for our orders compared to earlier industry benchmark of 80-120ms. Over 80% of all orders were processed in under 50ms.
DEXT Performance this month May 2024:
We push our latest update on DEXT by the end of April 2024, and here is how our order performance looks like for May 2024:
As of today, Dhan processes over 97% of all our orders in under 50 ms on DEXT. Compared to our earlier speed / response times in Feb & March, Dhan is 2X faster; and in comparison with our earlier benchmarks for the industry - Dhan is now 5X times faster in order processing and execution!
How are Orders handled? What happenâs behind the scenes at a Stock Trading Platform
Beyond just speeds, there is more to understand Order Processing on Dhanâs DEXT or any OMS Management System. Typically when you send an order to exchange via any stock trading platform - there are three most important legs in any transaction:
- Order Submit Flow
- Order & Risk Validation
- Final Updated Status of the Order
Letâs also understand what happenâs in each of the legs.
When you submit an Order to Exchange via a Stock Broker - many of the Stock Trading platforms (including Dhan) will try to do few or more validations on the front-end applications (web or mobile apps) itself - simpler ones like if the Trader has enough margins. Once you hit the âSubmit Order or Trade or Buy / Sellâ button on any Stock Broking platform - they instantly generate an Order ID in their system and submit the same to the exchange. This operation usually takes anywhere between 10 to 30 ms depending on the factors that I have mentioned above, large part of this being how the OMS (Order Management System) handles this.
Second leg, which is the most important part of any transaction is all the validations for the Order - which are multiple parameters including but not limited to Margin Available, Type of Scrip or Security, Leverage Provided, if any Open Position, Hegde Benefit to be given or not, and so on⌠these could depend on Order Type and could have anywhere from 50 to 150 parameters to be checked before the Order is finally sent to the exchange. If there is a queuing on the stock broker end - which is say too many orders or heavy utilisation of processes by the OMS, you will see messages like Validation Pending or similar. These Order and Risk verification operations usually take anywhere between 20 ms to 150 ms, once again it largely depends on which OMS handles this for the Stock Trading platform.
Third leg, is is fastest of all usually - where post the order is submitted to the exchange, the exchange will return to the Stock Trading platform the final status of the order, which the broking platform will update to the traderâs app or web that getâs done in about 5 ms.
Now depending on the Stock Broker, its OMS and its implementation - the above three legs of the transaction can be either done serially or in parallel. Earlier, Dhan use to process these transactions in a serial order, and from many months we do it in parallel.
This is how the impact of same is, below are older performance numbers:
These are latest performance numbers on DEXT for May 2024:
Please note the following when you consider the numbers:
- Dhan has its own exchange trading systems (DEXT) that makes all of this possible.
- These numbers are peak performance numbers for the entire day on a volatile day in markets, which includes high trading volumes across exchanges - NSE, BSE and MCX and across all segments.
- When it comes to APIs, consider additional 2-3 ms that gets added to the performance as result of rate limiting on DhanHQ trading APIs to avoid misuse.
- This performance includes large Iceberg orders, something that is very popular with large traders on Dhan
- Quick question - which orders take more time compared to others? The answer is advanced order types like Bracket, Cover and Trailing Stop-Loss that requires a few milli-seconds more than usual orders.
What is usually skipped in measuring Order / Trade Performance:
- We have noticed few threads and posts where usually only the first leg of the trade (Order Submitted to Exchange) is considered as a performance measure where the response comes via APIs that the order is submitted, however the next and most important leg of trade - Risk and Order Validation is skipped, which is technically incorrect way to measure the end to end performance.
- Additionally, we have also noticed that Trading Platforms that having similar underlying OMS platforms have been shown to have very different speeds of execution. This is likely for many reasons, however this wouldnât be very high differences in any cases.
- When it comes to APIs, few broking platforms may use wrappers around the front-end applications to process the trades and these do not connect directly to the core OMS. In such cases, there is an impact on the performance of order execution speeds.
- The underlying network and technology architecture is one of most important factors in deciding - peak user volumes, high trade volumes, and likes. These vary from broker to broker, and usually not considered in third party measures of performance.
Yes, so this is what goes under the hood when you place an order for execution on an Stock Trading platform. Hope this helps, and also makes anyone understand how complex trading systems are and what it takes to run a technology-led stock trading platform.
Specifically for Dhan - as of today, our orders 98% today are executed under 25-30 ms (end to end performance) for any day.
Best Regards,
pj