Skip to main content

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


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.1.tar.gz (123.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cython_orderbook-0.1.1-cp313-cp313-macosx_10_13_universal2.whl (250.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

File details

Details for the file cython_orderbook-0.1.1.tar.gz.

File metadata

  • Download URL: cython_orderbook-0.1.1.tar.gz
  • Upload date:
  • Size: 123.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for cython_orderbook-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e4fcc63efe40266eab40dc32f0837932945e9f63a900e96393a75f6f0910119b
MD5 e8ba297575e4f77a0cc9273bdbcd3d4a
BLAKE2b-256 e908aa07e4ac9e8c5eb484a87996cd3b98542f9627111f6765adba5d4d5884db

See more details on using hashes here.

File details

Details for the file cython_orderbook-0.1.1-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for cython_orderbook-0.1.1-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 8c6c7913e35ee94b5a60a6e8aad99ee61b6ea0f40b39b7053f4bc3f16447982a
MD5 19326b0b63b05b1c921f57b70d01cd7a
BLAKE2b-256 0e9ed823db5fc16528a0de926f76a13fce76c6137634559da47accffd5d8bf7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page