Skip to main content

Composable panel data and graph logic for quantitative research

Project description

BagelQuant Core

bagelquant-core is the Polars-native panel and graph layer for BagelQuant.

Panel data is long-form and keyed by time and asset_id. Numeric panels use a single value column:

import polars as pl

from bagelquant_core import Domain, Panel
from bagelquant_core.composer import div
from bagelquant_core.transformer import rank, zscore

static_domain = Domain(
    calendar=["2024-01-02", "2024-01-03"],
    universe=["AAA", "BBB"],
)
dynamic_domain = Domain(
    calendar=["2024-01-02", "2024-01-03"],
    universe=pl.DataFrame(
        {
            "time": ["2024-01-02", "2024-01-03"],
            "asset_id": ["AAA", "BBB"],
            "active": [True, True],
        }
    ),
)
domain = static_domain
price = Panel.from_domain(
    pl.DataFrame(
        {
            "time": ["2024-01-02", "2024-01-02"],
            "asset_id": ["AAA", "BBB"],
            "value": [100.0, 50.0],
        }
    ),
    domain,
    name="price",
)
book = Panel.from_domain(
    pl.DataFrame(
        {
            "time": ["2024-01-02", "2024-01-02"],
            "asset_id": ["AAA", "BBB"],
            "value": [40.0, 25.0],
        }
    ),
    domain,
    name="book",
)

factor = rank(zscore(div(book, price)), name="factor")
factor.compute()

print(factor.output.data)

Time-series operations group by asset_id and order by time. Cross-sectional operations group by time. Composer operations join inputs on (time, asset_id). Universes can be static lists/Series or sparse dynamic membership frames with time, asset_id, and boolean active; missing dynamic rows are inactive and are not forward-filled.

Development

uv run ruff check .
uv run python -m pytest

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

bagelquant_core-0.1.2.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

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

bagelquant_core-0.1.2-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file bagelquant_core-0.1.2.tar.gz.

File metadata

  • Download URL: bagelquant_core-0.1.2.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for bagelquant_core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f848479b5e2ea33b82455434e687cf51f59394f69b6adceddde0beb7e483d1e1
MD5 13573521ed6db8cfdf633927a8401e73
BLAKE2b-256 94fd270a662658f6b4b7958a547f93578a052658c30d5f3e2cd82faddcc477b5

See more details on using hashes here.

File details

Details for the file bagelquant_core-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for bagelquant_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1fe6729922ee7961db308ad3a7f7f3e5830cffaae1a669e267f5e245a721e4b0
MD5 ebcb4318387effdf6e3f613cf592b9e8
BLAKE2b-256 fbcb31e59800025d057ee33fcb2918a878161fb677785de58cbcdfbf55511cf8

See more details on using hashes here.

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