Skip to main content

Probalytics Python Client

Python client for Probalytics market data. Use it to query markets, fills, and orderbook snapshots directly from ClickHouse and return results as Polars or pandas dataframes.

Installation

pip install probalytics

The client requires Python 3.11 or newer.

Polars support is included by default. To use frame="pandas", install the pandas extra:

pip install "probalytics[pandas]"

Connect

from probalytics import ProbalyticsClient

client = ProbalyticsClient.from_clickhouse(
    host="clickhouse.probalytics.io",
    username="your_username",
    password="your_password",
)

By default, the client connects securely to the probalytics database. If your account uses a custom host, port, or database, pass those values when creating the client.

client = ProbalyticsClient.from_clickhouse(
    host="clickhouse.probalytics.io",
    port=9440,
    database="probalytics",
    username="your_username",
    password="your_password",
    secure=True,
    frame="polars",
)

You can also configure the client from environment variables:

export PROBALYTICS_CLICKHOUSE_USERNAME="your_username"
export PROBALYTICS_CLICKHOUSE_PASSWORD="your_password"
export PROBALYTICS_CLICKHOUSE_HOST="clickhouse.probalytics.io"
export PROBALYTICS_FRAME="pandas"
client = ProbalyticsClient.from_env()

Use the client as a context manager when you want the connection closed automatically:

with ProbalyticsClient.from_env() as client:
    markets = client.markets(platform="POLYMARKET", status="ACTIVE")

Query Markets

Markets are returned as typed Pydantic models.

markets = client.markets(
    market_platform_id="0xmarket",
    platform="POLYMARKET",
    status="ACTIVE",
    limit=100,
)

market = markets[0]
print(market.title)
print(market.platform)
print(market.platform_id)

You can also return markets as a dataframe.

markets_df = client.markets_frame(
    platform="KALSHI",
    status="ACTIVE",
    frame="polars",
)

Filters such as platform and status accept either one value or a list of values.

markets = client.markets(
    market_platform_id=["0xmarket", "KXBTC-26JUN-T50000"],
    platform=["POLYMARKET", "KALSHI"],
    status=["ACTIVE", "PAUSED"],
)

Query Fills

Fills return as a Polars dataframe by default.

fills = client.fills(
    market=market,
    start_time="2026-03-15T00:00:00Z",
    end_time="2026-03-16T00:00:00Z",
)

Use market, market_id, or market_platform_id to scope fills to one or more markets. A full market object is the most convenient option when you already loaded markets first.

fills = client.fills(market=market)
fills = market.fills()
fills = client.fills(market_id=market.id)
fills = client.fills(market_platform_id=market.platform_id, platform=market.platform)

market_id, market_platform_id, platform, taker_side, and trader_id also accept lists.

fills = client.fills(
    platform=["POLYMARKET", "KALSHI"],
    market_platform_id=["0xmarket", "KXBTC-26JUN-T50000"],
    taker_side=["BUY", "SELL"],
    start_time="2026-03-15T00:00:00Z",
)

Use a market selector or a bounded time range when querying fills. This keeps queries fast and avoids scanning more data than you need.

start_time / end_time filter timestamp (the exchange time) on fills and orderbook_snapshots, and created_at on markets — a market created months ago still returns today's fills.

Filter by participant or taker side:

fills = client.fills(
    market=market,
    trader_id="0x1234...",
    taker_side="BUY",
    start_time="2026-03-15T00:00:00Z",
)

If you need typed fill models instead of a dataframe:

fill_models = client.fills_models(
    market=market,
    start_time="2026-03-15T00:00:00Z",
)

fill_models = market.fills_models(
    start_time="2026-03-15T00:00:00Z",
)

Query Orderbook Snapshots

Orderbook snapshots are available for accounts with orderbook access.

book = client.orderbook_snapshots(
    market=market,
    start_time="2026-03-15T00:00:00Z",
    end_time="2026-03-15T00:01:00Z",
)

book = market.orderbook_snapshots(
    start_time="2026-03-15T00:00:00Z",
    end_time="2026-03-15T00:01:00Z",
)

Each snapshot is a complete replacement book for one outcome. Rows include indexed_at, hash, state, continuity, and path_index in addition to the market identifiers, outcome, bids, asks, and source timestamp.

state is VERIFIED or INTERMEDIATE. continuity is CONTIGUOUS (the transition from the previous book was provable), RESET (it was not — the first state of a book is deliberately RESET), or UNKNOWN for rows predating continuity tracking. Several distinct states can share one millisecond; hash separates them and path_index orders them within a recovered path.

Note that these columns were added to the warehouse in August 2026. Rows written before then read the column default rather than a measured value: hash is 0 before 2026-08-02, state reads VERIFIED before 2026-08-21, and continuity reads UNKNOWN before 2026-08-22.

Choose Polars or pandas

All dataframe methods return Polars by default. Set frame="pandas" when creating the client to use pandas globally. pandas support is optional; install it with pip install "probalytics[pandas]".

client = ProbalyticsClient.from_clickhouse(
    host="clickhouse.probalytics.io",
    username="your_username",
    password="your_password",
    frame="pandas",
)

You can also override the frame for a single call.

fills_pd = client.fills(
    market=market,
    start_time="2026-03-15T00:00:00Z",
    frame="pandas",
)

Invalid frame values fail early with a clear error. Supported values are "polars" and "pandas".

Run Custom SQL

Use query() for read-only ClickHouse queries when the convenience methods do not cover your use case.

from datetime import datetime, timezone

df = client.query(
    """
    SELECT platform, count() AS fills
    FROM fills
    WHERE timestamp >= %(start_time)s
    GROUP BY platform
    ORDER BY fills DESC
    """,
    parameters={"start_time": datetime(2026, 3, 15, tzinfo=timezone.utc)},
)

Always pass user-provided values through parameters instead of formatting them directly into SQL strings.

Unlike the convenience methods, query() passes parameters straight to ClickHouse — it does not parse date strings for you. Pass a datetime, or a string ClickHouse accepts such as "2026-03-15 00:00:00". An ISO string with a trailing Z is rejected by the server.

Supported Filters

The convenience methods return at most limit rows, and limit defaults to 1000. Raise it explicitly when you want more than that — results are truncated silently, not flagged.

markets() and markets_frame() support:

  • start_time
  • end_time
  • status or list of statuses
  • platform or list of platforms
  • market_id or list of market IDs
  • market_platform_id or list of market platform IDs
  • limit
  • max_rows

fills() and fills_models() support:

  • start_time
  • end_time
  • platform or list of platforms
  • market
  • market_id or list of market IDs
  • market_platform_id or list of market platform IDs
  • taker_side or list of taker sides
  • trader_id or list of trader IDs
  • limit
  • max_rows

orderbook_snapshots() supports:

  • start_time (required)
  • end_time (required)
  • platform or list of platforms
  • market
  • market_id or list of market IDs
  • market_platform_id or list of market platform IDs
  • state or list of states
  • continuity or list of continuity values
  • limit

Local Development

uv sync --extra test
uv run --extra test pytest

Run the ClickHouse integration tests with Docker:

PROBALYTICS_RUN_INTEGRATION=1 uv run --extra test pytest tests/test_clickhouse_integration.py

Use PYTHONPATH=src if running tests without installing the package into the active environment.

Metadata

Release files for probalytics 0.2.2

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

Source distribution (sdist)

Source distribution for probalytics 0.2.2
File Size Uploaded Provenance Actions
probalytics-0.2.2.tar.gz 19.6 kB With provenance Details for probalytics-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 35.9 kB

Release files / probalytics-0.2.2.tar.gz

Download URL probalytics-0.2.2.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a9c6556eb55490517384152417982fac4e6cbd8a4ad7de44917dcd3390f3d0cd
BLAKE2b-256 checksum
How to use checksums
2476a0ead14fb95c99a5e9205449bb39a4654991bf320d2feedaec8478989b49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / probalytics-0.2.2-py3-none-any.whl

Download URL probalytics-0.2.2-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dca81fe857cfb5c0d73d63685ab8f3afe951d6c57770a8b856c8c8801209775d
BLAKE2b-256 checksum
How to use checksums
23fd89dc5555fb507eadea8f96229326e16af78821bcfc6df8ff4c2ca87782d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for probalytics 0.2.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for probalytics-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

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