Computational Analysis of Greedy and Hash-Based Order Matching Algorithms for High-Frequency Trading
Authors
Department of Computer Science, Vellalar College for Women (Autonomous), Erode, India (India)
Department of Computer Science, Vellalar College for Women (Autonomous), Erode, India (India)
Article Information
DOI: 10.51583/IJLTEMAS.2026.150900125
Subject Category: Data Structures and Algorithm Analysis
Volume/Issue: 15/9 | Page No: 2598-2607
Publication Timeline
Submitted: 2026-09-25
Accepted: 2026-09-30
Published: 2026-10-19
Abstract
Fast and reliable trading is crucial in the world of High Frequency Trading (HFT) where automated systems make multiple trades in mere milliseconds. Order-matching techniques may perform differently when applied to different sets of data and different algorithms that process the data. In this study a Data Science based HFT Order Matching Engine is developed in MATLAB which is able to numerically process and compare two approaches (Greedy and Hash Based) for order matching on the same trading dataset. Based on price and quantity of buy and sell order, 3,000 order records were selected and preprocessed. Both algorithms were tried with the same matching conditions: an order is compatible if its buy price is no less than the price of the sell order, and the quantity of the matched order is the smallest available for the buy order and/or the sell order. Performance metrics of the algorithms included execution time, memory consumption, throughput, average matching time, number of matches and efficiency . A mathematical modelling based performance dashboard has also been created for the presentation of the experimental results in graphical and tabular form. Both algorithms generated 1420 matches and an equal number of matchable items 5207.978 and efficiency 49.26%. The Greedy algorithm took 0.256752 seconds to run, performing 11684.2 orders per second and an average matching time of 0.00018081 seconds per match. The Hash Based algorithm took 2.751413 seconds, 1090.32 orders/s, and had an average matching time of 0.00193761 seconds. Based on these results, in the experimental environment and the tested data set, the Greedy approach took less execution time, memory, and average matching time, and had greater throughput. The study emphasizes the key role of computational performance analysis for assessing order matching methods for HFT applications.
Keywords
High-Frequency Trading, Order Matching Engine, Data Science, Greedy Algorithm, Hash-Based Algorithm, Order Book, MATLAB, Performance Analysis.
This article is licensed under a Creative Commons Attribution 4.0 International License (CC BY 4.0).
Downloads
References
1. Aldridge I. High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Trading Systems. 2nd ed. Hoboken, NJ: John Wiley & Sons; 2013. https://doi.org/10.1002/9781119203803. [Google Scholar] [Crossref]
2. Aquilina M, Budish E, O’Neill P. Quantifying the high-frequency trading “arms race”. The Quarterly Journal of Economics. 2022;137(1):493–564. https://doi.org/10.1093/qje/qjab032. [Google Scholar] [Crossref]
3. Avellaneda M, Stoikov S. High-frequency trading in a limit order book. Quantitative Finance. 2008;8(3):217–224. https://doi.org/10.1080/14697680701381228. [Google Scholar] [Crossref]
4. Bouchaud JP, Farmer JD, Lillo F. How markets slowly digest changes in supply and demand. In: Hens T, Schenk-Hoppé KR, editors. Handbook of Financial Markets: Dynamics and Evolution. Amsterdam: North-Holland; 2009. P. 57–160. https://doi.org/10.1016/B978-012374258-2.50006-3. [Google Scholar] [Crossref]
5. Cartea Á, Jaimungal S, Penalva J. Algorithmic and High-Frequency Trading. Cambridge: Cambridge University Press; 2015. [Google Scholar] [Crossref]
6. Cont R, Stoikov S, Talreja R. A stochastic model for order book dynamics. Operations Research. 2010;58(3):549–563. https://doi.org/10.1287/opre.1090.0780. [Google Scholar] [Crossref]
7. Gould MD, Porter MA, Williams S, McDonald M, Fenn DJ, Howison SD. Limit order books. Quantitative Finance. 2013;13(11):1709–1742. https://doi.org/10.1080/14697688.2013.803148. [Google Scholar] [Crossref]
8. Harris L. Trading and Exchanges: Market Microstructure for Practitioners. New York: Oxford University Press; 2003. [Google Scholar] [Crossref]
9. Hasbrouck J, Saar G. Low-latency trading. Journal of Financial Markets. 2013;16(4):646–679. https://doi.org/10.1016/j.finmar.2013.05.003. [Google Scholar] [Crossref]
10. Hendershott T, Jones CM, Menkveld AJ. Does algorithmic trading improve liquidity? The Journal of Finance. 2011;66(1):1–33. https://doi.org/10.1111/j.1540-6261.2010.01624.x. [Google Scholar] [Crossref]
11. Hendershott T, Riordan R. Algorithmic trading and the market for liquidity. Journal of Financial and Quantitative Analysis. 2013;48(4):1001–1024. https://doi.org/10.1017/S0022109013000471. [Google Scholar] [Crossref]
12. Kirilenko A, Kyle AS, Samadi M, Tüzel T. The Flash Crash: High-frequency trading in an electronic market. The Journal of Finance. 2017;72(3):967–998. https://doi.org/10.1111/jofi.12498. [Google Scholar] [Crossref]
13. Law B, Viens F. Market making under a weakly consistent limit order book model. High Frequency. 2020;2(3–4):215–238. https://doi.org/10.1002/hf2.10050. [Google Scholar] [Crossref]
14. Madhavan A. Market microstructure: A survey. Journal of Financial Markets. 2000;3(3):205–258. https://doi.org/10.1016/S1386-4181(00)00007-0. [Google Scholar] [Crossref]
15. Menkveld AJ. High frequency trading and the new market makers. Journal of Financial Markets. 2013;16(4):712–740. https://doi.org/10.1016/j.finmar.2013.06.006. [Google Scholar] [Crossref]
16. Menkveld AJ. The economics of high-frequency trading: Taking stock. Annual Review of Financial Economics. 2016; 8:1–24. https://doi.org/10.1146/annurev-financial-121415-033010. [Google Scholar] [Crossref]
17. Sedgewick R, Wayne K. Algorithms. 4th ed. Boston: Addison-Wesley; 2011. [Google Scholar] [Crossref]
18. Gould MD, Porter MA, Howison SD. Quasi-centralized limit order books. Quantitative Finance. 2017;17(6):831–846. https://doi.org/10.1080/14697688.2016.1247980. [Google Scholar] [Crossref]
This work is licensed under CC BY 4.0