Skip to main content

Finkit Python Binding

This directory contains the Python package and PyO3 native extension for Finkit. The 0.4.0 PyPI distribution name is qx-finkit; the Python import name remains finkit.

Current release status

The v0.4.0 release adds a panel-factor API and publishes verified CPython ABI3 wheels for:

  • Linux x86_64;
  • Windows x86_64;
  • macOS x86_64;
  • macOS arm64.

The wheels use cp38-abi3 and are validated for GIL-enabled CPython 3.8-3.14 on the supported matrix.

Install a matching wheel from:

https://github.com/coeasy/finkit/releases/tag/v0.4.0

python -m pip install qx-finkit==0.4.0

The package exposes the Qlib-compatible alpha158 and alpha360 feature sets through finkit.feature_set(...). It also evaluates aligned time × symbols panels through built-in libraries and caller-supplied formula libraries. The full WorldQuant 101 formula corpus remains out of the release because redistribution rights have not been confirmed.

import numpy as np
import finkit as ta

timestamps = np.arange(3, dtype=np.int64)
symbols = ["AAA", "BBB"]
close = np.ascontiguousarray([[1., 10.], [2., 20.], [3., 30.]])
values = ta.evaluate_panel_formula(
    "MA(CS_RANK(CLOSE), 2)", timestamps, symbols, {"close": close}
)
assert values.shape == (3, 2)  # time × symbols

custom = ta.factor_library_from_expressions(
    "research-pack", {"momentum": "CLOSE / REF(CLOSE, 1) - 1"}
)
signals = custom.evaluate_panel_all(timestamps, symbols, {"close": close})
assert signals["momentum"].shape == (3, 2)

Source build

git clone https://github.com/coeasy/finkit.git
cd finkit
git checkout v0.4.0

python3 -m venv .venv
source .venv/bin/activate  # PowerShell: .\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install "maturin>=1.5,<2.0" "numpy>=1.24" pytest

cd ffi/python-binding
maturin develop --release
cd ../..
python -m pytest ffi/python-binding/tests -q

Basic usage

import numpy as np
import finkit as ta

close = np.arange(1.0, 101.0, dtype=np.float64)

sma20 = ta.sma(close, timeperiod=20)
rsi14 = ta.rsi(close, timeperiod=14)
macd, signal, hist = ta.macd(close, 12, 26, 9)

# The same versioned metadata is available to every official binding.
catalog_json = ta.operation_catalog_json()
compatibility_json = ta.formula_compatibility_report_json(
    "MA(CLOSE, 20)", "tdx"
)

Rolling indicators normally contain leading warm-up NaN values.

Reusable formulas

open_ = close - 0.25
high = close + 1.0
low = close - 1.0
volume = np.full(close.size, 1_000_000.0)

plan = ta.CompiledFormula("MA(CLOSE, 20)")
result = plan.eval(open_, high, low, close, volume)
ma20 = result["__result__"]

Register reusable parameterized combinations once and compile them through the same optimized runtime:

registry = ta.FormulaRegistry()
registry.register("ZMA", ["X", "N"], "MA(X, N) + EMA(X, N)")
plan = registry.compile("ZMA(CLOSE, 20)")
ma_combo = plan.eval(open_, high, low, close, volume)["__result__"]

Available reusable-plan operations include:

  • eval(...) — owned context, suitable before incremental append;
  • eval_zero_copy(...) — synchronous borrowed contiguous float64 NumPy inputs;
  • eval_range(..., start, end, ...) — half-open range evaluation;
  • eval_last(...) — latest value, with arrays or retained context;
  • append_bar(open, high, low, close, volume) — append one bar to retained context;
  • reserve_bars(additional) — reserve capacity before repeated append;
  • reset() — discard retained context while keeping the compiled formula.

For zero-copy calls, every OHLCV input must be a one-dimensional contiguous numpy.float64 array of equal nonzero length.

Pandas

Pandas is optional:

python -m pip install pandas

The package exports TaAccessor and register_accessor(). Explicit NumPy conversion remains a predictable integration path:

close = df["close"].to_numpy(dtype=np.float64, copy=False)
df["rsi14"] = ta.rsi(close, timeperiod=14)

Exceptions

The package exports stable wrapper exceptions:

  • FinkitError;
  • InsufficientDataError;
  • InvalidParameterError;
  • IndicatorNotFoundError.

Documentation

Metadata

Release files for qx-finkit 0.5.0

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

Built distributions (wheels)

Table of built distributions (wheels) for qx-finkit 0.5.0
File Actions
qx_finkit-0.5.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for qx_finkit-0.5.0-cp38-abi3-win_amd64.whl
qx_finkit-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for qx_finkit-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
qx_finkit-0.5.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for qx_finkit-0.5.0-cp38-abi3-macosx_11_0_arm64.whl
qx_finkit-0.5.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for qx_finkit-0.5.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 17.3 MB

Release files / qx_finkit-0.5.0-cp38-abi3-win_amd64.whl

Download URL qx_finkit-0.5.0-cp38-abi3-win_amd64.whl
Size 4.9 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1b8557a87e523bd76810fffb2676543bc1fa77c62b4eed0925fa61fa7236cabb
BLAKE2b-256 checksum
How to use checksums
5cf37e611621e7c000a7073c181d47de207d9172f0b76a1852d26cbbd66a022b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qx_finkit-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL qx_finkit-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
198a915f8b2f9644389bf87c99fbf6022dc44789e21ccee1a36791ebe553036f
BLAKE2b-256 checksum
How to use checksums
eb215b0e84ea86713597fefa28154b4cc4712afb02d3fdde2bc1db7a5e04b4b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qx_finkit-0.5.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL qx_finkit-0.5.0-cp38-abi3-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9168e53f3b959e02a96b120e6d170f7ece738c7da3e9c763e5294fbe9dfac470
BLAKE2b-256 checksum
How to use checksums
52ab2a95f638ede3f3497700c8bfcb352f94aed1bf813bcb74a3e1368c3cf987
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qx_finkit-0.5.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL qx_finkit-0.5.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 4.2 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
31e8c1c6e2b809d32698774cad4b10f8dd67506750cae9229cd8d8e3d953acc6
BLAKE2b-256 checksum
How to use checksums
5a0b2d66e1056b3a3dc9572b43f76397a58879e0c26e7339e0e66adbfb4f7c48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for qx-finkit 0.5.0

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