{"id":13815593,"url":"https://github.com/amankrx/matching-engine-rs","last_synced_at":"2025-05-15T09:32:40.795Z","repository":{"id":173769311,"uuid":"650705296","full_name":"amankrx/matching-engine-rs","owner":"amankrx","description":"Building a fast matching engine in Rust for efficient processing of an ITCH order book.","archived":false,"fork":false,"pushed_at":"2023-10-23T12:04:16.000Z","size":81,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-04T04:09:12.266Z","etag":null,"topics":["itch","limit-order-book","matching-engine","orderbook","rust","trading"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amankrx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-07T16:20:30.000Z","updated_at":"2024-07-27T13:12:46.000Z","dependencies_parsed_at":"2023-09-29T14:22:59.147Z","dependency_job_id":"3e66994a-807d-444e-b6ea-20804cd77144","html_url":"https://github.com/amankrx/matching-engine-rs","commit_stats":null,"previous_names":["amankrx/matching-engine-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amankrx%2Fmatching-engine-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amankrx%2Fmatching-engine-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amankrx%2Fmatching-engine-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amankrx%2Fmatching-engine-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amankrx","download_url":"https://codeload.github.com/amankrx/matching-engine-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225342796,"owners_count":17459475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["itch","limit-order-book","matching-engine","orderbook","rust","trading"],"created_at":"2024-08-04T04:03:38.639Z","updated_at":"2024-11-19T11:30:45.874Z","avatar_url":"https://github.com/amankrx.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# matching-engine-rs\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n[![Version](https://img.shields.io/badge/version-v1.0.0-blue.svg)](https://semver.org/)\n[![GitHub Stars](https://img.shields.io/github/stars/amankrx/matching-engine-rs?logo=github\u0026label=Stars\u0026color=yellow)](https://github.com/amankrx/matching-engine-rs)\n\nThis is an attempt to implement a matching engine with Rust. Currently, I have created an implementation of a Limit Order Book. The LOB offers fast processing of the ITCH data clocking at 11.3 Million messages per second (or a latency of 88 ns) as tested on my [local machine](#device-specifications). Checkout the [Performance](#performance) section for more information.\n\n## Table of Contents\n- [Project Structure](#project-structure)\n- [Build, Run, and Test](#build-run-and-test)\n- [Device Specifications](#device-specifications)\n- [Performance](#performance)\n- [ITCH Specifications](#itch-specifications)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n## Project Structure\nThese project consists of two libraries:\n- **[itch-parser](itch-parser)**: This library is responsible for managing the processing of *NASDAQ ITCH 5.0* protocol data. It parses the useful fields that will be required for the Limit Order Book. The remaining fields are skipped using placeholders. Check out the folder's [README](itch-parser/README.md) for more information.\n- **[optimized-lob](optimized-lob)**: This library contains a streamlined and efficient implementation of a Limit Order Book (LOB). It is worth noting that the LOB simply stores a few useful fields that will be required for creating a LOB. It just keeps an aggregate quantities at each level. Check out the folder's [README](optimized-lob/README.md) for more information.\n\nApart from that, there is a testing suite for both libraries that can be found in the \"[tests](tests)\" directory. \n\n## Build, Run, and Test\nMake sure you have Rust installed. Also, you must download the NASDAQ ITCH 5.0 data whose instructions are available in the [ITCH Specifications](#ITCH-Specifications). \nAll of these operations are performed in the `tests` directory. \n```bash\ncd tests\n```\n### Build\n```bash\ncargo build\n```\nor\n```bash\ncargo build --release\n```\n\n### Running the LOB\n```bash\nITCH_DATA=PATH_TO_ITCH_DATA_FILE cargo run\n```\nor\n```bash\nITCH_DATA=PATH_TO_ITCH_DATA_FILE cargo run --release\n```\n\n### Running the ITCH parser\n```bash\nITCH_DATA=PATH_TO_ITCH_DATA_FILE cargo run -- --itch-parser\n```\nor\n```bash\nITCH_DATA=PATH_TO_ITCH_DATA_FILE cargo run --release -- --itch-parser\n```\n\n### Testing\n```bash\ncargo test\n```\n\n\n## Device Specifications\nAt the time of testing:\n```text\nDevice: MacBook Air M2\nCPU architecture: Apple M2\nCPU logical cores: 8\nCPU physical cores: 8\nRAM total: 16 GB\nRAM free: 11.5 GB\n```\n## Performance\n\n### ITCH Processing\n\n```text\nITCH Parser Processing...\n\nSuccess...\n\nITCH Parsing Statistics:\nTotal Messages: 268744780\nTotal Time: 6.082 seconds\nSpeed: 44189583 msg/second\nLatency: 22 ns\n```\n\n### LOB Performance\n\n```text\nLOB Processing...\n\nSuccess...\n\nPerformance Metrics:\nTotal Messages: 268744780\nITCH Latency: 88 ns\nTotal Time: 23.660 seconds\nSpeed: 11358746 msg/second\n\nOrderbook Statistics:\nTotal Add Orders: 118631456\nTotal Execute Orders: 5822741\nTotal Cancel Orders: 2787676\nTotal Delete Orders: 114360997\nTotal Replace Orders: 21639067\n```\n## ITCH Specifications\n\u003c!-- itch-specs --\u003e\nThe project follows the `Nasdaq TotalView-ITCH 5.0` standard for the processing of data.\n\n- [Protocol Specifications](http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHSpecification.pdf)\n- [Binary Specification File](http://www.nasdaqtrader.com/content/technicalSupport/specifications/dataproducts/binaryfile.pdf)\n- ITCH data can be downloaded from their website: https://emi.nasdaq.com/ITCH/Nasdaq%20ITCH/\n\nI have specifically used their `12302019.NASDAQ_ITCH50` data whose compressed file can be downloaded from [here](https://emi.nasdaq.com/ITCH/Nasdaq%20ITCH/12302019.NASDAQ_ITCH50.gz).\n## Contributing\n\nContributions to matching-engine-rs are welcome! If you encounter any issues, have suggestions, or would like to add new features, please feel free to open an issue or submit a pull request. Note that I'm still learning my way around Rust and trading systems, so any feedback is appreciated!\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famankrx%2Fmatching-engine-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famankrx%2Fmatching-engine-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famankrx%2Fmatching-engine-rs/lists"}