Crypto-toolbox/HFT-Orderbook
FreeLimit Order Book for high-frequency trading (HFT), as described by WK Selph, implemented in Python3 and C
About Crypto-toolbox/HFT-Orderbook
HFT-Orderbook is an open-source implementation of a high-frequency trading (HFT) limit order book, originally described by WK Selph. Written in C for maximum performance, with an accompanying Python3 version (lob.py), it provides O(1) time complexity for core operations: add, cancel, and execute orders. The data structure uses a binary tree of Limit objects, each containing a doubly linked list of Order objects, plus hash maps for O(1) lookup by order ID and limit price. It efficiently supports queries like best bid/offer (top of book) and volume at a given price level. This library is ideal for developers building algorithmic trading systems or studying order book mechanics.
Key Features
Pros & Cons
- Core operations (add, cancel, execute) are O(1) - highly efficient
- Efficient querying of best bid/offer and volume at any limit
- Clean, well-documented design based on industry knowledge
- Open source and free to use, modify, and integrate
- C implementation ensures low latency
- Python3 version available for rapid prototyping
- Includes unit tests (orderbook_tests.py)
- Does not include networking, market data feeds, or trading strategy components
- Limited to limit order book functionality only; no support for other order types
- Python version may be slower than the C implementation
- Requires adaptation and integration for live trading environments
- No built-in persistence or logging mechanisms