[//]: # SSoT-OK
opendeviationbar-py
High-performance open deviation bar construction for quantitative trading, with Python bindings via PyO3/maturin.
| Resource | URL |
|---|---|
| PyPI | https://pypi.org/project/opendeviationbar/ |
| Repository | https://github.com/terrylica/opendeviationbar-py |
| Performance Dashboard | https://terrylica.github.io/opendeviationbar-py/ |
| API Reference | docs/api/INDEX.md |
| Issues | https://github.com/terrylica/opendeviationbar-py/issues |
Installation
pip install opendeviationbar
Pre-built wheels: Linux (x86_64), macOS (ARM64), Python 3.14. Source build requires Rust toolchain and maturin.
Quick Start
from opendeviationbar import get_open_deviation_bars
# Fetch data and generate open deviation bars in one call
df = get_open_deviation_bars("BTCUSDT", "2024-01-01", "2024-06-30")
# Use with backtesting.py
from backtesting import Backtest, Strategy
bt = Backtest(df, MyStrategy, cash=10000, commission=0.0002)
stats = bt.run()
Output: pandas DataFrame with DatetimeIndex and OHLCV columns, compatible with backtesting.py.
API Overview
| Function | Use Case |
|---|---|
get_open_deviation_bars() |
Date-bounded, auto-fetch |
get_n_open_deviation_bars() |
Exact N bars (ML training) |
process_trades_polars() |
Polars DataFrames (2-3x faster) |
process_trades_chunked() |
Large datasets (>10M trades) |
populate_cache_resumable() |
Long ranges (>30 days) |
run_sidecar() |
Real-time streaming sidecar |
# Count-bounded (ML training)
from opendeviationbar import get_n_open_deviation_bars
df = get_n_open_deviation_bars("BTCUSDT", n_bars=10000)
# Polars (2-3x faster)
import polars as pl
from opendeviationbar import process_trades_polars
bars = process_trades_polars(pl.scan_parquet("trades.parquet"), threshold_decimal_bps=250)
# With microstructure features (57 columns: OFI, Kyle lambda, Hurst, etc.)
df = get_open_deviation_bars("BTCUSDT", "2024-01-01", "2024-06-30", include_microstructure=True)
# Real-time streaming sidecar
from opendeviationbar import run_sidecar, SidecarConfig
config = SidecarConfig(symbol="BTCUSDT", threshold_decimal_bps=250)
run_sidecar(config)
Designed for Claude Code
This repository uses a CLAUDE.md network that provides comprehensive project context for AI-assisted development via Anthropic's Claude Code CLI.
npm install -g @anthropic-ai/claude-code
cd opendeviationbar-py
claude
Claude Code reads the CLAUDE.md files automatically and understands the full architecture, API, build system, and development workflow.
Development
git clone https://github.com/terrylica/opendeviationbar-py.git
cd opendeviationbar-py
proto install # Setup tools (Rust, Python, zig)
moon run odb:build # maturin develop
moon run odb:test # Rust tests
moon run odb:test-py # Python tests
Requirements
Runtime: Python >= 3.14, pandas >= 2.0, numpy >= 1.24, polars >= 1.0
Build: Rust toolchain, maturin >= 1.7
License
MIT License. See LICENSE.
Citation
@software{opendeviationbar-py,
title = {opendeviationbar-py: High-performance open deviation bar construction for quantitative trading},
author = {Terry Li},
url = {https://github.com/terrylica/opendeviationbar-py}
}
Metadata
Release files for opendeviationbar 13.91.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opendeviationbar-13.91.0.tar.gz | 22.6 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opendeviationbar-13.91.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 30.5 MB
Release files / opendeviationbar-13.91.0.tar.gz
| Download URL | opendeviationbar-13.91.0.tar.gz |
|---|---|
| Size | 22.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17dc68995a1c58d96fbec6d5303a6425ee812922c207150ca0d8f4b01f872128
|
|
BLAKE2b-256 checksum How to use checksums |
72a9846eba0ca3fcb5b0f8332cfba3013a5f32a38631ebba3b6c5cecb0d20650
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opendeviationbar-13.91.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | opendeviationbar-13.91.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.9 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
58a8cf7662c1b25a93df4e7aa3ad7a50624f3a1361b5133bd230dbb865852646
|
|
BLAKE2b-256 checksum How to use checksums |
18bf308242b1259354324d8630418e7081d44ac3bd6a291f9fd8e5b22d8fc88d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|