clob-sync 0.1.2

A synchronous, high-performance Central Limit Order Book implementation in Rust featuring an in-memory architecture with zero-cost abstractions and type-safe financial primitives for ultra-low latency trading applications.
Documentation
# CLOB-Sync

[![crates.io](https://img.shields.io/crates/v/clob-sync)](https://crates.io/crates/clob-sync)
[![docs.rs](https://img.shields.io/docsrs/clob-sync)](https://docs.rs/clob-sync)
[![License](https://img.shields.io/crates/l/LGPL-2.1)](LICENSE)
[![Downloads](https://img.shields.io/crates/d/clob-sync)](https://crates.io/crates/clob-sync)
[![MSRV](https://img.shields.io/badge/MSRV-1.88-blue)](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/)

A synchronous, high-performance Central Limit Order Book implementation in Rust featuring an in-memory architecture with zero-cost abstractions and type-safe financial primitives for ultra-low latency trading applications.

## Central Limit Order Book

A Central Limit Order Book (CLOB) is composed of two priority queues: asks (limit sell orders ordered low to high) and bids (limit buy orders ordered high to low). Orders at the same price are FIFO.

```
Price
  ^
  |     +---------+
  |     | $102 C  |  ← Worst Ask
  |     | $101 B  |
  |     | $100 A  |  ← Best Ask (lowest)
  |     +---------+
  |      spread
  |     +---------+
  |     | $99  X  |  ← Best Bid (highest)
  |     | $98  Y  |
  |     | $97  Z  |  ← Worst Bid
  |     +---------+
  +--------------------------> Quantity
```

## Order Behavior

- **Limit orders**: Not allowed to cross spread (buy price >= best ask, sell price <= best bid). Rests on book otherwise.
- **Market orders**: Execute immediately at best price. Partial fills when liquidity insufficient.

## Installation

Add this to your `Cargo.toml`:

<!-- x-release-please-start-version -->
```toml
[dependencies]
clob-sync = "0.1.2"
```
<!-- x-release-please-end -->

Or use `cargo add`:

```bash
cargo add clob-sync
```

## Development

```bash
git clone git@github.com:jfaleiro/clob-sync.git
cd clob-sync
```

```bash
make setup
```

Main development tasks are executed as a result of `git commit` and `git push` operations. 

Commit messages are validated during `commit-msg` phase of `git` hook and must be compatible with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).


## License

This project is licensed under the [GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.en.html). See the [LICENSE](LICENSE) file for details.