Skip to content

A lightweight and high-performance order-book designed to process level 2 and trades data

License

Notifications You must be signed in to change notification settings

miquelmalaga/ninjabook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ninjabook

Crates.io Documentation MIT licensed Rust

A lightweight and high-performance order-book designed to process level 2 and trades data.

Performance

Ran a couple of benchmarks showcasing real case scenarios against a naive Vec implementation and orderbook with fixed sizes of 100 and 500 levels.

The benchmarks are run with 300,000 events of level 2 orderbook data . This data is split in 2 chunks:

  • First 200,000 events are used to warm up.
  • Last 100,000 for the actual benchmark.

The scenarios tested are:

  • Process events and stream best bid and ask
  • Process events and stream top5 bids and asks

Here are the results:

bench iterations time ns/iter
ninjabook_bbo 100,000 9.1093 ms 91.093 ns
fixed_100_bbo 100,000 14.253 ms 142.53 ns
fixed_500_bbo 100,000 72.636 ms 726.36 ns
naive_bbo 100,000 263.77 ms 2,637.7 ns
ninjabook_top5 100,000 16.729 ms 167.29 ns
fixed_100_top5 100,000 23.532 ms 235.32 ns
fixed_100_top5 100,000 81.112 ms 811.12 ns
naive_top5 100,000 275.40 ms 2,754 ns

Contributing

To 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.

Any issues, refactoring, docs and tests are also welcomed. Feel free to reach out here if you have any questions.

About

A lightweight and high-performance order-book designed to process level 2 and trades data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%