Crates.io | rangebar |
lib.rs | rangebar |
version | 0.9.1 |
created_at | 2025-09-15 06:49:51.261793+00 |
updated_at | 2025-09-25 01:42:49.464597+00 |
description | Non-lookahead range bar construction for cryptocurrency trading with temporal integrity guarantees |
homepage | https://github.com/Eon-Labs/rangebar |
repository | https://github.com/Eon-Labs/rangebar |
max_upload_size | |
id | 1839503 |
size | 1,030,105 |
Non-lookahead range bar construction for cryptocurrency trading with temporal integrity guarantees.
Add this to your Cargo.toml
:
[dependencies]
rangebar = "0.5"
use rangebar::{RangeBarProcessor, AggTrade, FixedPoint};
// Create processor with 25 basis points threshold
let mut processor = RangeBarProcessor::new(25);
// Create sample aggTrade
let trade = AggTrade {
agg_trade_id: 1,
price: FixedPoint::from_str("50000.0").unwrap(),
volume: FixedPoint::from_str("1.0").unwrap(),
first_trade_id: 1,
last_trade_id: 1,
timestamp: 1609459200000,
is_buyer_maker: false,
};
// Process aggTrades into range bars
let trades = vec![trade];
let bars = processor.process_trades(&trades).unwrap();
for bar in bars {
println!("Bar: O={} H={} L={} C={} V={}",
bar.open, bar.high, bar.low, bar.close, bar.volume);
}
Range bars close when price moves ±threshold basis points from the bar's opening price:
MIT license. See LICENSE for details.