High-performance Python tools for market making systems
Reason this release was yanked:
invalid dist
Project description
MM Toolbox
MM Toolbox is a Python library designed to provide high-performance tools for market making strategies.
Contents
mm-toolbox/
├── src/
│ └── mm_toolbox/
│ ├── candles/ # Tools for handling and aggregating candlestick data
│ ├── logging/ # Lightweight logger + Discord/Telegram support
│ │ ├── standard/ # Standard logger implementation
│ │ └── advanced/ # Distributed HFT logger (worker/master)
│ ├── moving_average/ # Various moving averages (EMA/SMA/WMA/TEMA)
│ ├── orderbook/ # Multiple orderbook implementations & tools
│ │ ├── standard/ # Python-based orderbook
│ │ └── advanced/ # High-performance Cython orderbook
│ ├── ringbuffer/ # Efficient fixed-size circular buffers
│ ├── rounding/ # Fast price/size rounding utilities
│ ├── time/ # Time utilities
│ ├── websocket/ # WebSocket clients + verification tools
│ └── weights/ # Weight generators (EMA/geometric/logarithmic)
├── tests/ # Unit tests for all the modules
├── pyproject.toml # Project configuration and dependencies
├── LICENSE # License information
├── README.md # Main documentation file
└── setup.py # Setup script for building Cython extensions
Installation
MM Toolbox is available on PyPI and can be installed using pip:
pip install mm_toolbox
To install directly from the source, clone the repository and install the dependencies:
git clone https://github.com/beatzxbt/mm-toolbox.git
cd mm-toolbox
# Install uv if you haven't already: curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --all-groups
make build # Compile Cython extensions
Usage
After installation, you can start using MM Toolbox by importing the necessary modules:
from mm_toolbox import Orderbook
from mm_toolbox import ExponentialMovingAverage as EMA
from mm_toolbox.logging.standard import Logger, LogLevel, LoggerConfig
# Example usage:
ema = EMA(window=10, is_fast=True)
logger = Logger(
config=LoggerConfig(
base_level=LogLevel.INFO,
do_stdout=True
),
name="Example",
)
Latest release notes (v1.0.0)
Major Architecture Shift: Numba → Cython/C
MM Toolbox v1.0.0 represents a fundamental shift from Numba-accelerated code to Cython/C implementations. This transition brings significant benefits:
Performance Improvements: Core components now see speed improvements of 5–30x compared to previous Numba implementations, with some components achieving even greater gains.
Better Interoperability: Cython/C extensions integrate seamlessly with the Python ecosystem. Unlike Numba's JIT compilation, Cython extensions are pre-compiled, eliminating warm-up times and providing consistent performance from the first call. This makes MM Toolbox more suitable for production HFT systems where predictable latency is critical.
Type Safety & Tooling: Full type stub support (.pyi files) enables better IDE integration, static type checking with Pyright, and improved developer experience. Cython's explicit typing model also catches more errors at compile time.
Zero-Allocation Designs: Many components have been redesigned with zero-allocation patterns, reducing GC pressure and improving performance in tight loops.
Component Highlights
Candles (mm_toolbox.candles): High-performance candlestick aggregation supporting price, time, volume, and tick-based candles. New .next() method allows previewing next-state values without updating internal state, useful for backtesting and simulation scenarios.
Ringbuffer (mm_toolbox.ringbuffer): Efficient circular buffers with multiple implementations:
NumericRingBuffer: Fast numeric data handlingBytesRingBuffer: Optimized for byte arraysGenericRingBuffer: Flexible support for any Python typeSharedMemoryRingBuffer: IPC-capable shared memory buffers
New unified API provides both safe and unsafe access patterns, enabling zero-copy operations for performance-critical code paths.
Moving Average (mm_toolbox.moving_average): Comprehensive moving average implementations including EMA, SMA, WMA, and TEMA (Triple Exponential Moving Average). All implementations support .next() for previewing future values without state mutation.
Orderbook (mm_toolbox.orderbook): Dual implementation approach:
standard: Pure Python implementation for flexibilityadvanced: Zero-allocation Cython implementation achieving >4x faster BBO updates and >5x faster per-level batch updates
Websocket (mm_toolbox.websocket): Production-ready WebSocket client library:
SingleConnection: Auto-pinging, latency tracking, and raw data accessConnectionPool: Smart load balancing, latency-aware routing, and modular design- Built-in verification tools for message integrity
Logging (mm_toolbox.logging): Two-tier logging system:
standard: Lightweight logger with Discord/Telegram supportadvanced: Distributed HFT logger with worker/master architecture, batching, and customizable handlers
Rounding (mm_toolbox.rounding): Fast price/size rounding utilities optimized for trading operations.
Time (mm_toolbox.time): High-performance time utilities for timestamp operations.
Weights (mm_toolbox.weights): Weight generators for EMA, geometric, and logarithmic weighting schemes.
Breaking Changes
- API Unification: Some function signatures and parameter names have been standardized across components for consistency.
- Ringbuffer: Integer-specific ringbuffers removed; use
NumericRingBufferinstead. Multi-ringbuffer now supports any numeric type, strings, and bytes. - Numba Deprecation: Previous Numba implementations are no longer included. If you were using Numba-specific features, you'll need to migrate to the Cython equivalents.
Migration Guide
Most code should work with minimal changes. The primary differences are:
- Import paths remain the same (e.g.,
from mm_toolbox import ExponentialMovingAverage) - Performance characteristics are improved, so you may be able to simplify your code
- Type hints are now fully supported and recommended for better IDE support
Components not mentioned have either not incurred significant changes or maintain backward compatibility.
Planned additions/upgrades
v1.1.0 (no earlier than Jun 25')
Misc: Introduction of filter and limiter modules for data filtering and rate limiting utilities.
Orderbook: Further performance optimizations for orderbook operations.
Logger: AdvancedLogger performance improvements & two-way communication between Master<>Worker loggers, enabling health checks and remote shutdown capabilities.
Websocket: VerifyWsPayload performance improvements, FastWsPool optimizations.
v1.2.0
Parsers: Introduction of high-performance parsing utilities including JSON parsers and crypto exchange-specific parsers (e.g., Binance top-of-book parser).
Ringbuffer: Introduction of SharedMemoryRingBuffer for inter-process communication (IPC) scenarios, enabling efficient data sharing between processes.
v1.3.0
Stats: Introduction of statistical analysis tools including online moments, covariance calculations, quantiles, regression, and distribution fitting utilities.
License
MM Toolbox is licensed under the MIT License. See the LICENSE file for more information.
Contributing
Contributions are welcome! Please read the CONTRIBUTING.md for guidelines on how to contribute to this project.
Contact
For questions or support, please open an issue. I can also be reached on Twitter and Discord :D
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
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 mm_toolbox-1.0.0.tar.gz.
File metadata
- Download URL: mm_toolbox-1.0.0.tar.gz
- Upload date:
- Size: 159.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb896f7152b9683d8f5fa112188ed3eb298a91eb6bac5690ddf8e004197d2a39
|
|
| MD5 |
26f71a45b763870c7e5e89f021885bb7
|
|
| BLAKE2b-256 |
27d94edb3b5cb12a7b07894d476cf0824c8e04d96e1c35165ab4bcc2c1f9917f
|
File details
Details for the file mm_toolbox-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mm_toolbox-1.0.0-py3-none-any.whl
- Upload date:
- Size: 239.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e92eacda90f52efd864bfa3c0954bce9f5277ffe4b750d8b5cd768e1b9e9ced4
|
|
| MD5 |
176ab0f473be4f282ccb2f5ac4319b3b
|
|
| BLAKE2b-256 |
61a1a84ef88b50833568f75f649435baa19f36e9c24e3b2fb52ad19992c5c38a
|