Skip to main content

The Python toolkit for prediction market traders

Project description

predx

The Python toolkit for prediction market traders.

Screen markets, analyze microstructure, and build strategies on Polymarket and Kalshi — all from Python.

Install

pip install predx

No API keys needed for market data. Only trading requires authentication.

Quick Start

from predx.analytics import MarketScanner, to_df

scanner = MarketScanner()

# Find high-volume, tight-spread markets
markets = scanner.scan(min_volume_24h=50_000, max_spread=0.03)

# What moved the most today?
movers = scanner.movers(period="1d", limit=10)

# New markets gaining traction
trending = scanner.trending(max_age_hours=72)

# Drop into pandas
df = to_df(markets)
df[["question", "yes_price", "spread", "volume_24h", "price_change_1d"]].head()

Features

Market Discovery

from predx.analytics import MarketScanner, to_df

scanner = MarketScanner()

# Filter by volume, liquidity, spread, expiry, rewards eligibility
markets = scanner.scan(
    min_volume_24h=10_000,
    min_liquidity=50_000,
    max_spread=0.05,
    rewards_only=True,
    sort_by="volume_24h",
)

# Enrich with live orderbook depth
scanner.enrich(markets[:10])

# Export to DataFrame
df = to_df(markets)

Available filters: min_volume_24h, min_volume_1w, min_liquidity, min_open_interest, max_spread, min_best_bid, max_hours_to_expiry, min_hours_to_expiry, category, rewards_only, neg_risk

Sort options: volume_24h, volume_1w, volume_total, liquidity, spread, competitive, open_interest, price_change_1h, price_change_1d, price_change_1w, created_at

API Clients

from predx import PolymarketClient

# No auth needed for read-only access
with PolymarketClient() as pm:
    # Market discovery
    for market in pm.get_markets(active=True, max_items=50):
        print(market.title, market.yes_price)

    # Orderbook
    raw = pm.get_raw_market("condition-id-here")
    ob = pm.get_orderbook(raw.yes_token_id())
    print(ob.best_bid, ob.best_ask, ob.spread)

    # Price history, midpoint, trades
    mid = pm.get_midpoint(raw.yes_token_id())
    history = pm.get_price_history(raw.yes_token_id(), interval="1d")
    trades = list(pm.get_trades(max_items=100))

Polymarket — full read-only access with no API keys. Trading requires POLYMARKET_PRIVATE_KEY.

Kalshi — all endpoints require KALSHI_API_KEY + KALSHI_PRIVATE_KEY_PATH (RSA).

Data Models

All data is normalized into shared models that work across exchanges:

  • Market — price, volume, open interest, status, close time
  • Orderbook — bids/asks with best_bid, best_ask, mid, spread, depth()
  • Trade — price, size, side, timestamp
  • Position / Order — portfolio tracking

Project Structure

predx/
├── analytics/
│   └── discovery.py        # MarketScanner, movers, trending, to_df
├── clients/
│   ├── kalshi.py           # Kalshi REST API
│   └── polymarket.py       # Polymarket REST API (Gamma + CLOB + Data)
├── models/
│   └── common.py           # Shared data models (Market, Orderbook, Trade)
├── auth/                   # Exchange authentication
├── ws/                     # WebSocket clients
└── config.py               # Configuration

For example applications and strategies, see predx-apps.

Development

git clone https://github.com/achalps/predx.git
cd predx
pip install -e ".[dev]"
pytest tests/ -v

Auth Setup

Only needed for trading / Kalshi access:

# .env file
POLYMARKET_PRIVATE_KEY=0x...    # For placing orders on Polymarket
POLYMARKET_FUNDER=0x...         # Optional, for proxy wallets
KALSHI_API_KEY=...              # For any Kalshi access
KALSHI_PRIVATE_KEY_PATH=...     # Path to RSA private key

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

predx-0.2.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

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

predx-0.2.0-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: predx-0.2.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for predx-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a5096a664617511968321ddfb3bc1bcc281da7554a92a4771ba0bdfe43ecd5d1
MD5 ac30d7c20b15400022a8c1b3cb57e0bf
BLAKE2b-256 79a107b938d41c25494730dbb8d9759aee82e79ae6af1c05841644d894e94ed8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: predx-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for predx-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29015c0e8c15426952aeff1a0bf0eb6e159f7eab6afa2f94196a2c3c9a8f82cd
MD5 bf340b793160b9158d04bd882ba848f6
BLAKE2b-256 4b394c374bc731061fa36a76f4b482ec371b0bbb3ba36a879b80e93f0a7c56be

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