{"id":13815581,"url":"https://github.com/ninja-quant/ninjabook","last_synced_at":"2025-05-15T09:32:45.526Z","repository":{"id":232510960,"uuid":"784499436","full_name":"ninja-quant/ninjabook","owner":"ninja-quant","description":"A lightweight and high-performance order-book designed to process level 2 and trades data","archived":false,"fork":false,"pushed_at":"2024-04-14T00:57:25.000Z","size":2329,"stargazers_count":80,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T13:34:05.964Z","etag":null,"topics":["algorithms-and-data-structures","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/ninja-quant.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,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-10T01:01:10.000Z","updated_at":"2024-04-17T15:31:59.297Z","dependencies_parsed_at":"2024-04-17T15:31:57.926Z","dependency_job_id":null,"html_url":"https://github.com/ninja-quant/ninjabook","commit_stats":null,"previous_names":["ninja-quant/ninjabook"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninja-quant%2Fninjabook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninja-quant%2Fninjabook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninja-quant%2Fninjabook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninja-quant%2Fninjabook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ninja-quant","download_url":"https://codeload.github.com/ninja-quant/ninjabook/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":["algorithms-and-data-structures","trading"],"created_at":"2024-08-04T04:03:37.239Z","updated_at":"2024-11-19T11:30:46.837Z","avatar_url":"https://github.com/ninja-quant.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\n# ninjabook\n\n[![Pypi][pypi-badge]][pypi-url]\n[![Crates.io][crates-badge]][crates-url]\n[![Documentation][doc-badge]][doc-url]\n[![MIT licensed][mit-badge]][mit-url]\n[![Rust][rust-badge]][rust-url]\n\n[crates-badge]: https://img.shields.io/crates/v/ninjabook.svg\n[crates-url]: https://crates.io/crates/ninjabook\n[pypi-badge]: https://img.shields.io/pypi/v/ninjabook.svg\n[pypi-url]: https://pypi.org/project/ninjabook\n[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[mit-url]: https://github.com/ninja-quant/ninjabook/blob/main/LICENSE\n[doc-badge]: https://docs.rs/ninjabook/badge.svg\n[doc-url]: https://docs.rs/ninjabook\n[rust-badge]: https://shields.io/badge/rust-1.77.2%2B-blue.svg\n[rust-url]: https://github.com/ninja-quant/ninjabook\n\nA lightweight and high-performance order-book implemented in Rust, designed to process level 2 and trades data. \n\nAvailable in Python and Rust!\n\n# Getting started\n\nFind Python and Rust `hello_world` programs in the `examples` directory.\n\n# Performance\nRan a couple of benchmarks showcasing real case scenarios against a naive `Vec` implementation and an orderbook with a fixed size of 500 levels.\n\nThe benchmarks are run with [300,000 events of level 2 orderbook data](https://github.com/ninja-quant/ninjabook/blob/main/data/norm_book_data_300k.csv) . This data is split in 2 chunks:\n- First 200,000 events are used to warm up and verify all orderbook versions publish the same BBO and top5 levels.\n- Last 100,000 for the actual benchmark.\n\nThe scenarios tested are:\n- Process events and stream best bid and ask\n- Process events and stream top5 bids and asks\n\nHere are the results:\n|bench| iterations | time | ns/iter |\n|--|--|--|--|\n| ninjabook_bbo | 100,000 | 5.0108 ms | 50.108 ns | \n| fixed_500_bbo | 100,000 | 49.018 ms | 490.18 ns | \n| naive_bbo | 100,000 | 90.552 ms | 905.52 ns | \n| ninjabook_top5 | 100,000 | 11.797 ms | 117.97 ns | \n| fixed_500_top5 | 100,000 | 54.693 ms | 546.93 ns | \n| naive_top5 | 100,000 | 95.644 ms | 956.44 ns | \n\n# Contributing\nTo add a better version, create a new file, implementing the same methods as `orderbook.rs` (including tests) and add the improved orderbook to the bench `optimal_vs_naive.rs`. Only order books with a better performance than `orderbook.rs` will be considered. Lastly, add performance logs to the Pull Request, can just copy paste what `cargo bench` outputs.\n\n\nAny issues, refactoring, docs and tests are also welcomed. Feel free to reach out [here](https://twitter.com/ninjaquant_) if you have any questions.\n\n# Caveats\nJust some cosmetic improvements need to be done. Refactor `Orderbook` core functions into a `Trait`, add docs and potentially more tests/bench/examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninja-quant%2Fninjabook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fninja-quant%2Fninjabook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninja-quant%2Fninjabook/lists"}