Skip to main content

A high-performance order book implementation in Python

Project description

py-orderbook

A high-performance order book implementation in Python.

Features

  • Price-time priority matching engine
  • Limit and market order support
  • Order cancellation
  • 124k+ matched orders/second throughput

Installation & Setup

git clone https://github.com/Akhil4n/py-orderbook.git
cd py-orderbook
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

Usage

from orderbook import OrderBook, Order, MarketOrder, OrderSide
from decimal import Decimal

book = OrderBook()

# Add a limit order
order = Order(side=OrderSide.BID, price=Decimal("50.00"), original_quantity=100)
book.add_limit_order(order)

# Add a market order
market_order = MarketOrder(side=OrderSide.ASK, original_quantity=50)
book.add_market_order(market_order)

print(book) # displays current bids and asks

Running Tests

pytest test_orderbook.py -v

Project Structure

py-orderbook/
├── orderbook.py        # Core order book implementation
├── test_orderbook.py   # Unit tests
├── stress_test.py      # Performance benchmarks
└── requirements.txt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

akhil4n_orderbook-0.1.0-py3-none-any.whl (1.7 kB view details)

Uploaded Python 3

File details

Details for the file akhil4n_orderbook-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for akhil4n_orderbook-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6b3c86a737d33d5ed99279034208de86c23f43003974fd02124a3ca88be1616
MD5 6941bfd979a4f68319eca23660c878bf
BLAKE2b-256 19418c38fbe05961522925f94628d42e5c90e13372f1062117654cc94baac415

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