opendeviationbar-core
Core algorithm for non-lookahead open deviation bar construction from tick data, with 10 intra-bar and 16 inter-bar microstructure features computed during bar construction.
Installation
From crates.io
[]
= "12"
From git (latest)
[]
= { = "https://github.com/terrylica/opendeviationbar-py", = "crates/opendeviationbar-core" }
Quick Start
use ;
// Create processor: 250 dbps = 0.25% threshold
let mut processor = new?;
// Process a batch of trades
let bars = processor.process_agg_trade_records?;
for bar in &bars
Streaming (trade-by-trade)
use OpenDeviationBarProcessor;
let mut processor = new?;
for trade in trades
// Check for incomplete bar at end of session
if let Some = processor.get_incomplete_bar
Checkpoint (crash recovery)
use OpenDeviationBarProcessor;
use Checkpoint;
let mut processor = new?;
// ... process some trades ...
// Save state
let checkpoint = processor.create_checkpoint;
let json = to_string?;
// Later: restore from checkpoint
let restored_checkpoint: Checkpoint = from_str?;
let mut restored = from_checkpoint?;
// Continue processing from where we left off
let bars = restored.process_agg_trade_records?;
Threshold Units
All thresholds use decimal basis points (dbps): 1 dbps = 0.001% = 0.00001.
| dbps | Percentage | Use Case |
|---|---|---|
| 100 | 0.10% | Tight (scalping) |
| 250 | 0.25% | Standard |
| 500 | 0.50% | Wide (swing) |
| 1000 | 1.00% | Very wide |
Features
| Feature | Default | Description |
|---|---|---|
test-utils |
No | CSV loading for tests (adds csv dep) |
python |
No | PyO3 type exports |
api |
No | utoipa OpenAPI schemas |
arrow |
No | Arrow RecordBatch export |
Microstructure Features
10 intra-bar features computed during bar construction (zero additional passes):
ofi, vwap_close_deviation, kyle_lambda_proxy, trade_intensity, volume_per_trade, aggression_ratio, aggregation_density, turnover_imbalance, duration_us, price_impact
16 inter-bar lookback features from trades before each bar opens:
lookback_ofi, lookback_intensity, lookback_kyle_lambda, lookback_burstiness, lookback_hurst, lookback_permutation_entropy, and 10 more.
MSRV
Minimum supported Rust version: 1.90
License
MIT