Skip to main content

BQuant — Quantitative Research Toolkit

BQuant is a toolkit for quantitative research of financial markets. Its core is a universal zone-analysis pipeline: it is not tied to any particular indicator and works with any oscillator.

Install

pip install bquant

Python 3.12+.

Quick start

from bquant.data.samples import get_sample_data
from bquant.analysis.zones import analyze_zones

data = get_sample_data('tv_xauusd_1h')

# The pipeline is indicator-agnostic: swap the `.with_indicator()` call,
# everything else stays the same.
result = (
    analyze_zones(data)
    .with_indicator('pandas_ta', 'rsi', length=14)
    .detect_zones('threshold', indicator_role='value',
                  upper_threshold=70, lower_threshold=30)
    .analyze(clustering=True)
    .build()
)

print(len(result.zones))                              # 64
print(sorted({zone.type for zone in result.zones}))   # ['neutral', 'overbought', 'oversold']

A zone is addressed by role (indicator_role='value'), not by column name. Column names depend on the library and on the call parameters and change with them; roles do not.

MACD zones in one line — a preset over the same pipeline:

from bquant.analysis.zones import analyze_macd_zones
from bquant.data.samples import get_sample_data

result = analyze_macd_zones(get_sample_data('tv_xauusd_1h'))

print(len(result.zones))                              # 30
print(sorted({zone.type for zone in result.zones}))   # ['bear', 'bull']

Note that the zone vocabulary follows the indicator: an oscillator crossing zero yields bull/bear, a bounded one yields overbought/neutral/oversold.

What is in the box

Zone analysis. Five detection strategies (zero_crossing, threshold, line_crossing, preloaded, combined) and five metric families (swing, shape, divergence, volatility, volume), plus hypothesis testing and clustering over the resulting zones.

Indicators. Built-in implementations (SMA, EMA, RSI, MACD, Bollinger Bands) and anything from pandas-ta or TA-Lib through one factory:

from bquant.data.samples import get_sample_data
from bquant.indicators import LibraryManager

data = get_sample_data('tv_xauusd_1h')

LibraryManager.load_all_libraries()
rsi = LibraryManager.create_indicator('pandas_ta', 'rsi', length=14)

print(rsi.calculate(data).data.columns.tolist())   # ['RSI_14']

Evaluation of trades. A frame of trades is checked for consistency rather than read off one backtest number: a block bootstrap over calendar months, the advantage over a random entry of the same year, side and holding time, a Benjamini–Hochberg correction for everything that was tried, rule objects with thresholds, a pick-on-back / trade-forward procedure evaluator and a quarterly measure (bquant.analysis.evaluation).

Data. OHLCV loading, processing and validation, with sample datasets embedded in the package so that every example runs without external files.

Visualization. Interactive financial charts and statistical plots (Plotly, Matplotlib).

Performance. Vectorized computation and a two-level cache (memory + disk).

Command line

bquant list                                  # available sample datasets
bquant analyze tv_xauusd_1h                  # zones, MACD by default
bquant analyze tv_xauusd_1h --indicator rsi  # any supported oscillator
bquant analyze --json --no-chart             # structured output, for programs
bquant analyze mt_xauusd_m15 -o chart.html   # save the chart

Every flag and the JSON schema: CLI guide.

Documentation

Quick start first result in five minutes
Zone analysis pipeline the full builder reference
Tutorials step-by-step scenarios
API reference module by module
Developer guide extending the package

Development

git clone https://github.com/kogriv/bquant.git
cd bquant
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest

Extras: dev, docs, notebooks, research, and full (= dev + notebooks).

Repository layout: bquant/ is the package itself; tests/, docs/ and examples/ support it; research/ and scripts/ hold notebook-style studies and automation.

Status

Beta. The public API changes between releases without deprecation windows — renames are carried through in one change. Pin an exact version: bquant>=0.0.23,<0.0.24.

Breaking changes ship in the patch number, and the dangerous ones do not raise: when a defect in a calculation is fixed, nothing fails to import — your numbers change, and the old ones were wrong. Every breaking change is marked in CHANGELOG.md on a line naming its replacement, so one command lists them:

grep -nE "Ломает:|\(breaking\)" CHANGELOG.md

The full policy — what counts as breaking here, how to move a pin, what the project does not promise — is docs/versioning.md.

Not in the package: machine learning. The bquant.ml placeholder was removed in 0.0.7 because both of its public functions only ever raised NotImplementedError.

License

MIT — see LICENSE.

Contact

Author: kogriv · kogriv@gmail.com

Metadata

Release files for bquant 0.0.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bquant 0.0.23
File Size Uploaded Provenance Actions
bquant-0.0.23.tar.gz 1.4 MB Without provenance Details for bquant-0.0.23.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bquant 0.0.23
File Interpreter ABI Platform Actions
bquant-0.0.23-py3-none-any.whl Python 3 none any Details for bquant-0.0.23-py3-none-any.whl

Total release size: 2.0 MB

Release files / bquant-0.0.23.tar.gz

Download URL bquant-0.0.23.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
08de140969cc42aedad19bd3dcda7e5599a2452e91476deaabd1f86d43339700
BLAKE2b-256 checksum
How to use checksums
e84e51f75bc44421390e580db8b18954902b70f9da9f53f10b4b7fae52723cfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / bquant-0.0.23-py3-none-any.whl

Download URL bquant-0.0.23-py3-none-any.whl
Size 561.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fff0e5c8d7b22e300ed2f62c969a09cb906424f729ad38df8eb64d3ccc780c5
BLAKE2b-256 checksum
How to use checksums
4872b6380b7f4cc7ef6f5d13ed7d1d9279a4c1e9a53a167d25fdd4495c803033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for bquant 0.0.23

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page