High-performance exchange feed parser and orderflow analytics engine with Rust and Python bindings
Project description
fastreader
🚀 High-performance binary market data parser and order book engine for Python, powered by Rust + PyO3.
Overview
fastreader is a high-performance Python library built with Rust and PyO3 for parsing exchange binary feed files and constructing order books efficiently.
The library is designed for:
- Quantitative trading systems
- HFT research
- Tick-level backtesting
- Exchange feed analysis
- Order flow analytics
- Order book reconstruction
- Ultra-fast binary parsing
Unlike traditional Python parsers, fastreader executes the heavy parsing logic in Rust, delivering significantly better speed and lower memory overhead.
Features
✅ Ultra-fast binary message parsing
✅ Rust-powered backend for maximum performance
✅ Python-friendly API
✅ Parse order and trade messages
✅ Token-based filtering
✅ Cursor-based streaming access
✅ Batch message processing
✅ Top-of-book order book reconstruction
✅ Efficient memory handling
✅ Built for large exchange data files
Installation
Install from PyPI
pip install orderpulse
Upgrade to Latest Version
pip install -U orderpulse
Quick Start
Import Library
from fastreader import ReadMsgFromBinary, OrderBookBuilder
Load Binary Feed File
reader = ReadMsgFromBinary("market_data.bin")
Get Summary
reader.summary()
Output:
Total Messages: 1520000
Total Orders: 1300000
Total Trades: 220000
Core Classes
1. ReadMsgFromBinary
Main parser class used to read exchange binary files.
Constructor
ReadMsgFromBinary(path, token=None)
Parameters
| Parameter | Type | Description |
|---|---|---|
| path | str | Binary file path |
| token | int (optional) | Filter messages by token |
Example: Read Full File
from fastreader import ReadMsgFromBinary
reader = ReadMsgFromBinary("data.bin")
Example: Token Filtered Reading
reader = ReadMsgFromBinary(
"data.bin",
token=26000
)
Only messages belonging to token 26000 will be loaded.
Available Methods
total_messages()
Returns total parsed messages.
count = reader.total_messages()
print(count)
total_orders()
Returns total order messages.
orders = reader.total_orders()
print(orders)
total_trades()
Returns total trade messages.
trades = reader.total_trades()
print(trades)
summary()
Prints complete message summary.
reader.summary()
reset_cursor()
Resets internal message cursor.
Useful when iterating incrementally.
reader.reset_cursor()
Message Extraction APIs
get_all_messages()
Returns all parsed messages.
messages = reader.get_all_messages()
With Limit
messages = reader.get_all_messages(limit=10)
get_order_messages()
Returns only order messages.
orders = reader.get_order_messages()
With Limit
orders = reader.get_order_messages(limit=5)
get_trade_messages()
Returns only trade messages.
trades = reader.get_trade_messages()
With Limit
trades = reader.get_trade_messages(limit=5)
Incremental Reading
get_next_msg()
Reads one message at a time.
Ideal for streaming-style processing.
while True:
msg = reader.get_next_msg()
if msg == "END":
break
print(msg)
MessageBatch
MessageBatch is a lightweight container used for efficient message selection and downstream processing.
Selection APIs
select_all_messages()
Returns all messages as a MessageBatch.
batch = reader.select_all_messages()
select_order_messages()
Returns only order messages.
order_batch = reader.select_order_messages()
select_trade_messages()
Returns only trade messages.
trade_batch = reader.select_trade_messages()
select_next_messages(limit)
Returns next N messages using internal cursor.
batch = reader.select_next_messages(100)
Useful for chunk-wise processing of very large files.
MessageBatch Methods
len()
Returns number of messages.
print(batch.len())
is_empty()
Checks whether batch is empty.
print(batch.is_empty())
to_list()
Converts batch into Python list.
data = batch.to_list()
With Limit
data = batch.to_list(limit=10)
OrderBookBuilder
The OrderBookBuilder reconstructs top-of-book snapshots using parsed order and trade messages.
Create Builder
from fastreader import OrderBookBuilder
ob = OrderBookBuilder()
create_orderbook_all_messages()
Builds order book using all messages from reader.
rows = ob.create_orderbook_all_messages(reader)
print(rows)
create_orderbook()
Build order book from a MessageBatch.
batch = reader.select_order_messages()
rows = ob.create_orderbook(batch)
Example: Complete Workflow
from fastreader import ReadMsgFromBinary
from fastreader import OrderBookBuilder
# Load file
reader = ReadMsgFromBinary(
"market_data.bin",
token=26000
)
# Print summary
reader.summary()
# Get first 10 messages
msgs = reader.get_all_messages(limit=10)
for msg in msgs:
print(msg)
# Select order messages
batch = reader.select_order_messages()
# Build order book
ob = OrderBookBuilder()
rows = ob.create_orderbook(batch)
print("Generated Rows:", rows)
Message Format
Messages are returned as formatted strings.
Example:
Order Message: SeqNo12345, msg_len64, Msg_Type'O', Exch_ts123456789, local_ts123456790, order_id11111, Token26000, order_Type'B', Price25000, Quantity100, missed0
Message Fields
| Field | Description |
|---|---|
| SeqNo | Stream sequence number |
| msg_len | Packet length |
| Msg_Type | Exchange message type |
| Exch_ts | Exchange timestamp |
| local_ts | Local receive timestamp |
| order_id | Order identifier |
| order_id_buy | Buy order ID |
| order_id_sell | Sell order ID |
| Token | Instrument token |
| order_Type | Order type |
| Price | Order/trade price |
| Quantity | Quantity |
| missed | Gap indicator |
Performance
fastreader is optimized for:
- Large binary files
- Low-latency parsing
- Efficient memory usage
- High throughput message processing
Because parsing logic is implemented in Rust, performance is significantly faster than pure Python implementations.
Use Cases
- Tick data analysis
- HFT research
- Exchange feed decoding
- Backtesting engines
- Order flow analytics
- Market microstructure research
- Real-time strategy simulation
- Order book reconstruction
Why Rust + PyO3?
This library combines:
Rust
- Memory safety
- High speed
- Zero-cost abstractions
- Parallel-friendly architecture
Python
- Easy integration
- Quant ecosystem support
- Data science workflows
- Rapid research iteration
Result:
🔥 Production-grade performance with Python simplicity.
Recommended Workflow
Binary Feed File
↓
ReadMsgFromBinary
↓
MessageBatch Selection
↓
OrderBookBuilder
↓
Analytics / Alpha / Backtesting
Future Roadmap
Planned improvements:
- Direct NumPy export
- Pandas DataFrame support
- Async streaming parser
- Multi-threaded parsing
- Depth-wise order book snapshots
- CSV export
- Arrow / Parquet integration
- Real-time websocket ingestion
Contributing
Contributions are welcome.
You can contribute by:
- Reporting bugs
- Improving performance
- Adding exchange decoders
- Extending order book logic
- Writing benchmarks
- Improving documentation
License
MIT License
Author
Built for quantitative trading and ultra-fast market data processing.
If this library helps your research or trading workflow, consider starring the repository.
Support
If you encounter issues:
- Open a GitHub issue
- Share sample binary data
- Include stack trace/output
- Mention library version
⚡ fastreader — Rust Speed. Python Simplicity.
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 orderpulse-0.2.16.tar.gz.
File metadata
- Download URL: orderpulse-0.2.16.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5746a164dce65d223615433addfb1e062547c5cf6303228ffebedaea859a4168
|
|
| MD5 |
e561277e9759a43c96966d86dfe4b9a1
|
|
| BLAKE2b-256 |
a4d747ad76cbd5eef9a10e6e32cacf32c270fdb2fa2a23b7aef4df7d243300df
|
File details
Details for the file orderpulse-0.2.16-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: orderpulse-0.2.16-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 247.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c13bc22422dbd35be5e4c7f9f0262f669f62a972ee475a840e31ee8359726e49
|
|
| MD5 |
2eb74c0fcb67444bf197c5c8eb981cce
|
|
| BLAKE2b-256 |
0eb8663a1fd9d1d441cba03eccf5d6c39e4894259bb9b4863d0e2e1334dabc11
|