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

Overview

ninjabook

Pypi Crates.io Documentation MIT licensed Rust

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

Available in Python and Rust!

Getting started

Find Python and Rust hello_world programs in the examples directory.

Performance

Ran a couple of benchmarks showcasing real case scenarios against a naive Vec implementation and an orderbook with a fixed size of 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 and verify all orderbook versions publish the same BBO and top5 levels.
  • 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 5.0108 ms 50.108 ns
fixed_500_bbo 100,000 49.018 ms 490.18 ns
naive_bbo 100,000 90.552 ms 905.52 ns
ninjabook_top5 100,000 11.797 ms 117.97 ns
fixed_500_top5 100,000 54.693 ms 546.93 ns
naive_top5 100,000 95.644 ms 956.44 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.

Caveats

Just some cosmetic improvements need to be done. Refactor Orderbook core functions into a Trait, add docs and potentially more tests/bench/examples.

You might also like...
KAIVM is a multiplatform Command Line Interface (CLI) designed to simplify the process of downloading, managing, configuring, and running different versions of Shinkai Node
KAIVM is a multiplatform Command Line Interface (CLI) designed to simplify the process of downloading, managing, configuring, and running different versions of Shinkai Node

KAIVM - Shinkai Version Manager KAIVM is a multiplatform Command Line Interface (CLI) designed to simplify the process of downloading, managing, confi

Command-line tool designed to simplify the process of managing multiple .NET SDK versions on your system

.NET Version Manager (dver) Overview dver is a command-line tool designed to simplify the process of managing multiple .NET SDK versions on your syste

Rust For Data book

Rust For Data This book is available for free online at https://rustfordata.com You can find the source code for book in ./rust4data-book This book is

EmbedAnything is a powerful python library designed to streamline the creation and management of embedding pipelines
EmbedAnything is a powerful python library designed to streamline the creation and management of embedding pipelines

EmbedAnything is a powerful python library designed to streamline the creation and management of embedding pipelines. Built in Rust with no heavy dependencies.

Designed as successor to Pretty-Good-Video for improved codec structure, API design & performance

Pretty Fast Video Minimal video codec designed as a successor to Pretty Good Video Goals are to improve: Quality API design Codec structure (Hopefully

httm prints the size, date and corresponding locations of available unique versions of files residing on ZFS snapshots

httm prints the size, date and corresponding locations of available unique versions of files residing on ZFS snapshots, as well as allowing their interactive viewing and restoration.

Extract core logic from qdrant and make it available as a library.
Extract core logic from qdrant and make it available as a library.

Qdrant lib Why? Qdrant is a vector search engine known for its speed, scalability, and user-friendliness. While it excels in its domain, it currently

Tricking shells into interactive mode when local PTY's are not available
Tricking shells into interactive mode when local PTY's are not available

Remote Pseudoterminals Remote Pseudoterminals or "RPTY" is a Rust library which intercepts calls to the Linux kernel's TTY/PTY-related libc functions

Holo is a suite of routing protocols designed to support high-scale and automation-driven networks.

Holo is a suite of routing protocols designed to support high-scale and automation-driven networks. For a description of what a routing protocol is, p

Owner
Ninja Quant
Ninja Quant
Poisson intensity of limit order execution, calibration of parameters A and k using level 1 tick data

Poisson intensity of limit order execution, calibration of parameters A and k using level 1 tick data Description A limit order placed at a price St ±

0xCuteSocks 6 Apr 9, 2023
Abuse the node.js inspector mechanism in order to force any node.js/electron/v8 based process to execute arbitrary javascript code.

jscythe abuses the node.js inspector mechanism in order to force any node.js/electron/v8 based process to execute arbitrary javascript code, even if t

Simone Margaritelli 301 Jan 4, 2023
A high-performance Rust library designed to seamlessly integrate with the Discord API.

Rucord - Rust Library for Discord API Interactions Note: This library is currently under development and is not yet recommended for production use. Ov

Coders' Collab 4 Feb 26, 2023
The Amp programming language: a language designed for building high performance systems.

A language designed for building high performance systems. Platform Support x86_64-pc-windows ✅ x86_64-unknown-linux ⚠️ untested x86_64-unknown-darwin

The Amp Programming Language 5 Mar 17, 2023
Local-first high performance codebase index engine designed for AI

CodeIndex CodeIndex is a local-first high performance codebase index engine designed for AI. It helps your LLM understand the structure and semantics

Jipiti AI 9 Aug 30, 2023
High-performance, low-level framework for composing flexible web integrations

High-performance, low-level framework for composing flexible web integrations. Used mainly as a dependency of `barter-rs` project

Barter 8 Dec 28, 2022
Schemars is a high-performance Python serialization library, leveraging Rust and PyO3 for efficient handling of complex objects

Schemars Introduction Schemars is a Python package, written in Rust and leveraging PyO3, designed for efficient and flexible serialization of Python c

Michael Gendy 7 Nov 21, 2023
A Rust on-site channel benchmarking helper. Inter-Process (async / busy) & Intra-Process (async single threaded / async multi threaded)

On-Site Rust Channel Benchmarking Helper Deploy on server to determine which public crates are the fastest for communicating in different architecture

null 23 Jul 9, 2024
Rust-powered CLI tool designed to simplify and streamline the release process with help of ChatGPT

$ releasecraftsman ????‍♂️?? Automate Your Release Process with Precision and Ease. ?? Features Generate well-crafted release notes using GPT-3.5 and

Tornike Gomareli 7 Sep 21, 2023
A high-performance WebSocket integration library for streaming public market data. Used as a key dependency of the `barter-rs` project.

Barter-Data A high-performance WebSocket integration library for streaming public market data from leading cryptocurrency exchanges - batteries includ

Barter 23 Feb 3, 2023