Skip to main content

Polars-native technical features for trading pipelines — pure, point-in-time, online-ready

Project description

sabia

Polars-native technical features for trading pipelines — pure, point-in-time, online-ready.

sabia reads price/volume into features, grounded in the trading & finance literature. It is the features brick in a layered stack:

marketgoblin (data in) → sabia (features) → quale (signals)

Runtime dependencies are just polars and numpy. (The stack's calendar brick quando will be wired in when calendar-aware seasonality or the microstructure tier needs it — v1 seasonality is pure vectorized datetime.) Risk/eval math lives in ruin; signals live in quale. sabia computes features and nothing else.

What it is

Pure factories over OHLCV bars. A factory binds its params and returns a BoundFeature — an immutable .spec plus a .expr(schema) -> pl.Expr that resolves column roles (close@tr, high@split) against a caller-supplied BarSchema. Features are strictly trailing, point-in-time correct, and deterministic. Batch-first, online-ready: nothing streams in v1, but every feature declares the history it needs and is covered by a windowed-recompute parity test, so a future online engine is a thin wrapper rather than a rewrite.

Install

uv sync --extra dev

Quickstart

import polars as pl
import sabia
from sabia import BarSchema, PriceRole, PriceField, Adjustment

frame = ...  # OHLCV LazyFrame/DataFrame; see sabia.validate for the input contract

# A BarSchema maps your physical column names to roles. sabia adjusts nothing — you declare which
# adjustment basis each column carries.
schema = BarSchema(roles={
    PriceRole(PriceField.OPEN,  Adjustment.SPLIT): "open",
    PriceRole(PriceField.HIGH,  Adjustment.SPLIT): "high",
    PriceRole(PriceField.LOW,   Adjustment.SPLIT): "low",
    PriceRole(PriceField.CLOSE, Adjustment.SPLIT): "close",
    PriceRole(PriceField.CLOSE, Adjustment.TR):    "close",
})

# Factories return BoundFeature objects; compute resolves roles against the schema and materializes:
df = sabia.compute(frame, sabia.momentum.rsi(period=14), sabia.volatility.vol_yz(window=21),
                   schema=schema)

# Query the registry by horizon or data tier:
reg = sabia.Registry.default()
reg.where(lambda s: sabia.Horizon.MEDIUM in s.native_band)
reg.available(sabia.DataTier.DAILY)

Invariants

Causality · point-in-time correctness · purity (no I/O, clocks, randomness) · Polars-native (no pandas) · determinism within a declared tolerance. All enforced by tests, not convention. See FEATURES.md for the full spec.

License

MIT

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

sabia-0.2.0.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

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

sabia-0.2.0-py3-none-any.whl (55.6 kB view details)

Uploaded Python 3

File details

Details for the file sabia-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for sabia-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b6e22cee6aef53121ab7cd5d9612b956efe8afea4b0a391bbcf2ad6ab86bbc2d
MD5 496d3e59f8838f577da9e3c8f2f58841
BLAKE2b-256 5bd06f9c137f7e08c3936a8c3196dee801c4f501e2e7f00596eb6d61510e4bca

See more details on using hashes here.

Provenance

The following attestation bundles were made for sabia-0.2.0.tar.gz:

Publisher: publish.yml on aexsalomao/sabia

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

File details

Details for the file sabia-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sabia-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 55.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sabia-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fe9d5512883038152335779fef7472f734d9f173cd9b5c87cf745978affb1d9
MD5 7f3ce017a38e8c2720b4868d8175f1d1
BLAKE2b-256 df6cb521dfcd441c4cb3a1d42a8152f882f791f4409d6b711752914f5fc2a757

See more details on using hashes here.

Provenance

The following attestation bundles were made for sabia-0.2.0-py3-none-any.whl:

Publisher: publish.yml on aexsalomao/sabia

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