rangebar
High-performance non-lookahead bias range bar construction for Binance UM Futures data.
[!NOTE] This crate processes 137M+ trades/second using fixed-point arithmetic for financial-grade precision.
[!WARNING] Range bars use non-lookahead bias - thresholds are computed only from bar opening prices, never from evolving high/low ranges.
Quick Start
Add this to your Cargo.toml:
[]
= "0.4.1"
Basic Usage
use ;
// Create processor with 0.8% threshold (8000 basis points)
let mut processor = new;
// Create sample trade data
let trade = AggTrade ;
// Process trades into range bars
let trades = vec!;
let bars = processor.process_trades.unwrap;
for bar in bars
Algorithm
Range bars close when price moves ±threshold% from the bar's opening price:
- Non-lookahead bias: Thresholds computed only from bar open price
- Breach inclusion: Breaching trade included in closing bar
- Fixed thresholds: Never recalculated during bar lifetime
Features
statistics(default): Comprehensive statistical analysis via Polarsdata-integrity(default): Data validation and checksumsarrow-support: Apache Arrow and Parquet exportpython-bindings: PyO3 Python bindings (optional)
Performance
- 137M+ trades/second processing (2025 benchmarks)
- Fixed-point arithmetic (no floating-point errors)
- Memory efficient streaming processing
- Zero-copy design where possible
Data Source
Designed for Binance UM Futures aggTrades data:
// Sample aggTrade format
License
MIT license. See LICENSE for details.