admin 发表于 2026-3-1 09:00:45

rangebar 12.33.0:高性能量化交易范围条构建工具

rangebar 12.33.0:高性能量化交易范围条构建工具

作者:James Bentley
来源:Pypi.org
引用:https://pypi.org/project/rangebar/12.33.0/

rangebar-py 是一款专为量化交易设计的高性能范围条构建工具,它通过 PyO3/maturin 提供了 Python 绑定。该工具资源丰富,包括 PyPI 链接、代码仓库、性能仪表板和 API 文档。

### 安装

使用 pip 安装 rangebar:

bash

pip install rangebar

预构建的 wheel 包支持 Linux (x86_64)、macOS (ARM64) 和 Python 3.13。源码构建需要 Rust 工具链和 maturin。

### 快速入门

python

from rangebar import get_range_bars

df = get_range_bars("BTCUSDT", "2024-01-01", "2024-06-30")

生成的 pandas DataFrame 包含 DatetimeIndex 和 OHLCV 列,与 backtesting.py 兼容。

### API 概览

- `get_range_bars()`: 日期范围自动获取数据并生成范围条。

- `get_n_range_bars()`: 获取精确数量的范围条,适用于机器学习训练。

- `process_trades_polars()`: 使用 Polars DataFrame(速度快 2-3 倍)处理交易数据。

- `process_trades_chunked()`: 处理大型数据集(>10M 交易)。

- `populate_cache_resumable()`: 处理长范围(>30 天)数据。

- `run_sidecar()`: 实时流式传输侧边栏。

### 设计理念

rangebar-py 针对 Claude Code 进行了优化,使用 Anthropic 的 Claude Code CLI 提供的项目上下文,以支持 AI 辅助开发。

### 开发

bash

git clone https://github.com/terrylica/rangebar-py.git

cd rangebar-py

mise install# 安装工具(Rust、Python、zig)

mise run build# 使用 maturin 构建

mise run test# 运行 Rust 测试

mise run test-py# 运行 Python 测试

### 要求

- 运行时:Python >= 3.13,pandas >= 2.0,numpy >= 1.24,polars >= 1.0。

- 构建:Rust 工具链,maturin >= 1.7。

### 许可证

MIT 许可证。请参阅 LICENSE 文件。

### 引用

(https://github.com/terrylica/rangebar-py) 提供了详细的引用信息。
页: [1]
查看完整版本: rangebar 12.33.0:高性能量化交易范围条构建工具