Skip to main content

Polars-native factor research engine powered by Rust

Project description

qweave

中文

CI Release Python License

A Polars-native factor research engine powered by Rust. qweave takes you from composable alpha computation and leakage-aware forward-return labels to IC, quantile, turnover, and interactive report analysis in one DataFrame pipeline.

  • 4.8M rows × 158 factors in ~2.2 s: all Qlib Alpha158 factors on a 6,000-symbol × 800-day panel in one batch run (measured on a Ryzen 9 9950X).
  • 🆚 23.85× faster than Qlib Alpha158DL: measured on the same panel, the same factor set, and 32 threads for every engine; 2.56× faster end to end than KunQuant's JIT C++ path, with no C++ toolchain required. Commands and full data in Benchmarks.
  • 🧩 259 built-in classic factors: WorldQuant Alpha101 + Qlib Alpha158, with time-series and cross-sectional operators in one expression API — select, remap inputs, mix, and execute them as one batch.
  • 📊 Interactive report in one line: result.view() opens the embedded Vue + ECharts interface with per-factor quantile returns, monthly IC, and long-short diagnostics.

qweave pipeline from market data to factor report

Bring your own Polars market-data panel. Keep your data pipeline. Move the expensive factor-research loop into Rust.

qweave is for quantitative researchers who already manage data with Parquet/Polars and want fewer per-factor Python loops, repeated rolling computations, and matrix-alignment problems. It focuses on whether factors carry stable information about future returns. It is not a data vendor, matching simulator, or full investment platform.

Installation

Install directly from GitHub Releases (CPython 3.10+ stable ABI):

# Windows x64
python -m pip install https://github.com/GaomingOrion/qweave/releases/download/v0.5.0/qweave-0.5.0-cp310-abi3-win_amd64.whl
# Linux x86_64
pip install https://github.com/GaomingOrion/qweave/releases/download/v0.5.0/qweave-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

# macOS arm64
pip install https://github.com/GaomingOrion/qweave/releases/download/v0.5.0/qweave-0.5.0-cp310-abi3-macosx_11_0_arm64.whl

Wheels for other platforms (Linux aarch64, macOS x86_64) are on the Releases page. For source builds see the Development Guide.

From Market Data To A Factor Report

The repository includes a deterministic synthetic panel with 80 assets and 320 trading days. This example mixes two classic factors with one custom expression, then creates labels, evaluates the factors, and opens the interactive report:

import polars as pl
import qweave as qw

df = pl.read_parquet("examples/data/sample_daily.parquet")

alphas = qw.worldquant_alpha101({}, alphas=["alpha13", "alpha101"])
alphas.append(
    (-(qw.col("close") / qw.col("close").delay(20) - qw.lit(1.0)))
    .alias("mean_reversion_20")
)

df = qw.with_alphas(df, "asset", "date", alphas)
df = qw.with_labels(
    df,
    symbol_col="asset",
    time_col="date",
    horizons=[1, 5, 20],
    entry_lag=1,
    tradable_col="tradable",
)

result = qw.evaluate(
    df,
    symbol_col="asset",
    time_col="date",
    factor_cols=["alpha13", "alpha101", "mean_reversion_20"],
    quantiles=5,
    min_cs_count=30,
    tradable_col="tradable_entry",
)

print(result.summary)
result.view()   # opens the interactive evaluation report in your browser

Or run the complete example directly:

python examples\quickstart.py

qweave interactive factor report: click a factor row to open its quantile-return, long-short, and IC tearsheets

Why qweave

  • DataFrame in, DataFrame out: qweave takes and returns Polars DataFrames directly — no converting the panel to NumPy arrays and stitching results back, and no migration to a dedicated data provider.
  • Cross-sectional and time-series factors in the same expression: cross-sectional operators like rank and group_neutralize live in the same DAG as rolling time-series operators, so one compute_alphas call runs everything — no staged provider/handler workflow that fetches features first and organizes cross-sectional computation separately.
  • Execute the whole factor batch once: expressions enter one Rust DAG with common-subexpression reuse, intermediate-slot reuse, fused elementwise chains, and node-level parallelism.
  • 259 composable classic factors: WorldQuant Alpha101 and Qlib Alpha158 use the same API as custom expressions, so they can be selected, remapped, mixed, and executed together.
  • Reports included: result.view() opens the Vue + ECharts interactive interface with per-factor drill-down. Thousand-factor workloads can stream results to Parquet.

Performance: Head-To-Head With Qlib And KunQuant

Measured on Windows 11 / Ryzen 9 9950X (16 cores, 32 threads) / 61.7 GiB memory, on the same 6,000-symbol × 800-day (4.8M-row) synthetic OHLCV panel, 32 threads for every engine, best of three runs after one warmup. KunQuant is measured end to end in f64, including input/output DataFrame conversion and JIT compilation:

Workload qweave Competitor Takeaway
All 158 Qlib Alpha158 factors 2.24 s Qlib Alpha158DL: 53.37 s 23.85× faster, about 46% less peak RSS
WorldQuant Alpha101 (82 factors) 3.11 s KunQuant f64: 7.95 s 2.56× faster end to end, about 31% less peak RSS, no C++ toolchain

Where the speed comes from: sorting, rolling windows, cross-sectional operators, and evaluation statistics run on the Rust hot path; the whole expression batch enters one DAG with common-subexpression reuse, slot reuse, and node-level parallelism managed by the engine. Full environment, commands, and publishing conventions in Benchmarks.

Factor Evaluation: Leakage-Free, Everything In One Run

Signal T ── entry_lag ──> Entry T+1 ── horizon h ──> Exit T+1+h
  • T+1 entry by default, no look-ahead; halts and missing rows cannot silently shorten the holding period, and entry-day tradability is aligned back to the signal day automatically.
  • One evaluate call produces IC/RankIC, quantile returns, turnover, rank autocorrelation, and long-short diagnostics, with Newey–West t-statistics correcting overlapping-horizon significance.
  • result.view() opens the interactive report directly; thousand-factor runs can stream to Parquet.

See Factor Evaluation for exact calibers and parameters.

When To Choose qweave

  • Your market data already lives in a Parquet/Polars pipeline and you do not want to migrate to a platform-specific data format or a staged provider/handler workflow just to compute factors.
  • You compute and evaluate tens to thousands of factors at a time, and per-factor Python loops have become the bottleneck of research iteration.
  • You are building automated factor mining or a research agent: an easy-to-write expression API, high-throughput batch execution, and unified evaluation calibers make qweave a natural kernel for an agent's "generate → compute → evaluate" experiment loop.

When you need a full platform with data ingestion, model training, and backtest experiment management, Qlib is the better fit — and qweave can be embedded in such platforms or agent systems as the factor computation and evaluation kernel. See Comparison for details.

Roadmap

  • An experiment kernel for research agents: an easy-to-write expression API, high-throughput batch execution, and unified evaluation calibers powering the automated "generate factors → batch compute → strict evaluate" factor-mining loop.
  • Publish to PyPI so installation becomes a single pip install qweave.
  • Expand the built-in factor libraries and time-series/cross-section operators.
  • Keep improving the interactive report as the default way to inspect evaluation results.

Documentation Path

Follow the documentation home in order:

  1. Runnable example
  2. Python Expression API
  3. WorldQuant 101 / Qlib Alpha158
  4. Factor Evaluation
  5. Architecture / Benchmarks

Project Status

The factor-computation, labeling, evaluation, and reporting workflow is usable today, while the API remains pre-1.0.

See CONTRIBUTING to contribute. This project is not affiliated with WorldQuant, Microsoft, Qlib, or KunQuant.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qweave-0.5.0.tar.gz (472.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qweave-0.5.0-cp310-abi3-win_amd64.whl (10.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

qweave-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

qweave-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

qweave-0.5.0-cp310-abi3-macosx_11_0_arm64.whl (9.9 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

qweave-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl (10.4 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file qweave-0.5.0.tar.gz.

File metadata

  • Download URL: qweave-0.5.0.tar.gz
  • Upload date:
  • Size: 472.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qweave-0.5.0.tar.gz
Algorithm Hash digest
SHA256 fbe3a549eea8f0feff8d6a287e169f2d919c735ad6fad921cf5639c7abeba5a5
MD5 6bec61acda5697c4896c08ca82e23821
BLAKE2b-256 80e953046c3ede76d51e6f88620f3ed4abf2891b163ba9be3d0ceb64bdff815d

See more details on using hashes here.

Provenance

The following attestation bundles were made for qweave-0.5.0.tar.gz:

Publisher: release.yml on GaomingOrion/qweave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qweave-0.5.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: qweave-0.5.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 10.1 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qweave-0.5.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3313fb5ae7230887a238603df5738c042c5be3c4eca1c3e8f198c41d02b66b1c
MD5 10682063d2acf8dcc3ae6e1b61dbe84d
BLAKE2b-256 33fa5297c9938156c5238bd817d0bfcb2e77112cac5a5cacb559d262c9ace5bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for qweave-0.5.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on GaomingOrion/qweave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qweave-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qweave-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b7d8d31762c17e209cce0d4e0ed65975c7bab5c0c8c884d092853d7127db794
MD5 c5f115f7ce6b1a2ca23197b83ad73404
BLAKE2b-256 1a18e6d504dda4ae751adf1d1888603fcf79671ab35dcb43e8bb9052bb53c5b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for qweave-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on GaomingOrion/qweave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qweave-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for qweave-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c1a9d886d8aca2400132fca137fadc30c3ef42d5458d6fd92b3617fb3905302f
MD5 a8ad8ef6797dc57fa910d0768fdb2911
BLAKE2b-256 04bdd443e2a4156e1ab27a4a809b15ecb8b22215c4b5372cb126418b85f9956e

See more details on using hashes here.

Provenance

The following attestation bundles were made for qweave-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on GaomingOrion/qweave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qweave-0.5.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qweave-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 408bc15fd603a8a7e9b5a38e0507f37bfdbf850793103cb226ac155bcc6ec1ae
MD5 b0e0e894b339cd585aeac525b44bf0cf
BLAKE2b-256 d4f2ebd6ca3bb0799f911b27b592835eadfc65ef7ba7fef63179a031ddde2c8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for qweave-0.5.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on GaomingOrion/qweave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qweave-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qweave-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a660aca19e11bcf186017407017e79e5b6b822487dff935369b099aa693e56c9
MD5 22953461fbdd96b3483a6f900c70be7a
BLAKE2b-256 0303ad721e9559242842f9c69fa2d48f3541a23d71c9f430285560ebcf49c7b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for qweave-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on GaomingOrion/qweave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page