A high-performance order book implementation using Cython
Project description
cython-orderbook
A high-performance order book implementation in Python with Cython acceleration and price-time priority matching. Available as an official PyPI package.
Installation
pip install cython-orderbook
Features
- Price-time priority matching engine
- Limit and market order support
- Order cancellation
- Trade log with aggressor tracking
- 670k+ matched orders/second throughput (5.4x faster than pure Python)
Usage
from cython_orderbook import OrderBook, Order, OrderSide
from decimal import Decimal
book = OrderBook()
# Add a limit order
bid = Order(side=OrderSide.BID, price=Decimal("50.00"), original_quantity=100)
book.add_limit_order(bid)
# Add a matching ask
ask = Order(side=OrderSide.ASK, price=Decimal("50.00"), original_quantity=100)
book.add_limit_order(ask)
# Add a market order (no price needed)
market_order = Order(side=OrderSide.BID, original_quantity=50)
book.add_market_order(market_order)
# Cancel an order
book.cancel_order(bid.order_id)
# Display the book
print(book)
# View trade log
book.print_trade_log()
Performance
Simple inserts: ~1.49M orders/second
Matched pairs: ~670k orders/second
Mixed actions: ~610k orders/second
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cython_orderbook-0.1.0.tar.gz
(123.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cython_orderbook-0.1.0.tar.gz.
File metadata
- Download URL: cython_orderbook-0.1.0.tar.gz
- Upload date:
- Size: 123.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b02a56d7f71dd36bf421d47ad38fc0bf149784e6535bf54444c4a4a7929b926
|
|
| MD5 |
5b4a6ceffeb1a6255e157b998969112a
|
|
| BLAKE2b-256 |
80ca02e71b0c29e77f4fb56d570749f1e94101e07cea893277926c15e481528c
|
File details
Details for the file cython_orderbook-0.1.0-cp313-cp313-macosx_10_13_universal2.whl.
File metadata
- Download URL: cython_orderbook-0.1.0-cp313-cp313-macosx_10_13_universal2.whl
- Upload date:
- Size: 249.4 kB
- Tags: CPython 3.13, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
744345771e5a581965f0d835f2711965cba3bb55812285fd6b4c6eb0239fb1b4
|
|
| MD5 |
c61407dda30c21d833beb825c55d3e28
|
|
| BLAKE2b-256 |
b2187f89f50c915f45f056f4f9f3e296cdb6f3dbdfc4af45a8440e1734ed1ef4
|