Prediction market websocket clients for Polymarket, Kalshi, and Opinion
Project description
predxt
Read-only realtime ingestion for prediction market builders.
predxt streams and normalizes websocket data from Polymarket, Kalshi, and
Opinion. It is built for dashboards, recorders, research tools, monitoring
agents, and orderbook visualizations. It is not a trading, execution, account, or
financial-advice library.
Install
pip install predxt
For local development:
uv sync --group dev
uv run pytest -q -s
60-second Polymarket demo
Polymarket market websockets are public. Use any valid Polymarket CLOB asset id:
predxt stream polymarket --asset-id 1234567890 --limit 5 --jsonl
Or from Python:
import asyncio
from predxt.polymarket import PolymarketWsClient
async def main() -> None:
client = PolymarketWsClient()
await client.connect()
await client.subscribe(
["market"],
{"assets_ids": ["1234567890"], "initial_dump": True},
)
async for message in client.messages():
print(message.event_type, message.asset_id, message.raw_data)
break
await client.close()
asyncio.run(main())
Venue matrix
| Venue | Public stream | Auth | Current support |
|---|---|---|---|
| Polymarket | Yes | None for market stream | market books, price changes, trades |
| Kalshi | No | signed websocket headers | orderbook snapshots and deltas |
| Opinion | No | API key | depth diffs, last price, last trade |
API contract
Core imports:
from predxt import (
OrderBookState,
VenueMessage,
typed_event_from_message,
)
Venue imports:
from predxt.polymarket import PolymarketWsClient, PolymarketSubscriptionConfig
from predxt.kalshi import KalshiWsClient, build_kalshi_auth_headers
from predxt.opinion import OpinionWsClient, OpinionSubscriptionConfig
Every client emits VenueMessage objects with:
venueevent_typemarket_idasset_idtimestamp_msreceived_at_msraw_data
Use typed_event_from_message(message) when you want dataclass events such as
OrderBookSnapshot, OrderBookDelta, TradeEvent, or PriceChangeEvent.
Use OrderBookState when you need a small in-memory orderbook helper.
CLI
Offline parser demo:
predxt parse-fixture --venue polymarket --jsonl tests/fixtures/polymarket_order_books.json
Live streams:
predxt stream polymarket --asset-id 1234567890 --limit 10 --jsonl
KALSHI_KEY_ID=... KALSHI_PRIVATE_KEY_PATH=... predxt stream kalshi --market MARKET-TICKER
OPINION_API_KEY=... predxt stream opinion --market-id 2764
Examples
This repository keeps minimal examples in examples/. Public showcase starters:
hzprotocol/predxt-orderbook-tui- terminal orderbook monitor
hzprotocol/predxt-web-dashboard- FastAPI + React dashboard
hzprotocol/predxt-agent-market-monitor- read-only agent/MCP starter
What this is not
predxt does not place orders, derive trading credentials, manage positions,
execute arbitrage, bypass venue restrictions, or provide financial advice. It is
a read-only ingestion SDK. Keep account secrets in environment variables or a
secret manager; never hard-code them in examples or agent prompts.
Documentation
- Docs site: https://hzprotocol.github.io/predxt
- AI context:
llms.txt,llms-full.txt - Codex skill:
skills/predxt/SKILL.md
Development
uv sync --group dev
uv run ruff check .
uv run mypy
uv run pytest -q -s
uv build
uv run twine check dist/*
Release
Releases use SemVer and tags like v0.1.0. See
docs/releasing.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file predxt-0.1.0.tar.gz.
File metadata
- Download URL: predxt-0.1.0.tar.gz
- Upload date:
- Size: 44.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86c378353e6fe30482439fb85692bb9938d51ace700d2f062d3a0a7c75434a7b
|
|
| MD5 |
3c41365b5b3b8b03ef174a50bc51eac2
|
|
| BLAKE2b-256 |
aefb82f42e7d5efc30ed9006370948c5904c18fc619f3d5f721ba59c86790ec1
|
Provenance
The following attestation bundles were made for predxt-0.1.0.tar.gz:
Publisher:
release.yml on hzprotocol/predxt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predxt-0.1.0.tar.gz -
Subject digest:
86c378353e6fe30482439fb85692bb9938d51ace700d2f062d3a0a7c75434a7b - Sigstore transparency entry: 1705783645
- Sigstore integration time:
-
Permalink:
hzprotocol/predxt@14a04f315dd6a25a2ef7ea22ee77ffe372c940da -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hzprotocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14a04f315dd6a25a2ef7ea22ee77ffe372c940da -
Trigger Event:
push
-
Statement type:
File details
Details for the file predxt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: predxt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c5c96b2fe94fd8284d13518fcb1f473bd341ad48f3bf4843badcbf88e57c690
|
|
| MD5 |
23589919b244b8181bb2eeb0c7c6f661
|
|
| BLAKE2b-256 |
9bb5a9526b5d879ecd5de05e421f8979678996063559bd211f4be9d7fa9395d1
|
Provenance
The following attestation bundles were made for predxt-0.1.0-py3-none-any.whl:
Publisher:
release.yml on hzprotocol/predxt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predxt-0.1.0-py3-none-any.whl -
Subject digest:
0c5c96b2fe94fd8284d13518fcb1f473bd341ad48f3bf4843badcbf88e57c690 - Sigstore transparency entry: 1705783668
- Sigstore integration time:
-
Permalink:
hzprotocol/predxt@14a04f315dd6a25a2ef7ea22ee77ffe372c940da -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hzprotocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14a04f315dd6a25a2ef7ea22ee77ffe372c940da -
Trigger Event:
push
-
Statement type: