Skip to main content

Python trading client for Polymarket

Project description

PolyTrader

PyPI version Python License: MIT

A Python trading client for Polymarket — the world's largest prediction market.

Documentation

Features

  • Order Management — Limit (GTC/GTD), market (FOK/FAK), and post-only orders with full cancel support
  • Real-time WebSocket — Market data (order book, price changes, trades, BBO) and authenticated user events (order updates, trade confirmations)
  • Binance Integration — aggTrade, kline, and depth streams for cross-market signals
  • Typed Models — All data parsed into msgspec.Struct with Decimal prices and StrEnum statuses
  • Position & Balance Tracking — Query positions, USDC balance, and conditional token balances
  • On-chain Operations — Token and collateral approvals with optional builder/relayer support

Installation

pip install polytrader

Quick Start

from decimal import Decimal
from polytrader import PolyTrader, OrderSide, Coin, Timeframe

trader = PolyTrader(
    private_key="0x...",
    funder="0x...",
    signature_type=0,
)

# Get current Up/Down market
market = await trader.get_current_updown_market(Coin.BTC, Timeframe.M5)

# Place a limit order
result = trader.create_order(
    token_id=market.up_token_id,
    side=OrderSide.BUY,
    price=Decimal("0.50"),
    size=Decimal("10"),
)

# Cancel all orders
trader.cancel_all_orders()
# Real-time market data
await trader.market_ws.connect()
await trader.market_ws.subscribe([market.up_token_id], callback)
await trader.market_ws.run()

See the Getting Started guide for setup details and configuration options.

Documentation

Full documentation is available at omidroshani.github.io/polytrader.

Contributing

Contributions are welcome! To get started:

git clone https://github.com/omidroshani/polytrader.git
cd polytrader
uv sync --group dev --group docs

Run checks before submitting a PR:

make check    # mypy + ruff lint + ruff format
make test     # pytest
make security # bandit

License

This project is licensed under the MIT License.

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

polytrader-0.1.5.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

polytrader-0.1.5-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file polytrader-0.1.5.tar.gz.

File metadata

  • Download URL: polytrader-0.1.5.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for polytrader-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bf1fdfa81107c699aa287a789cc77bebeef44a9142bff9794292a3c7faabe79b
MD5 9251d5826f26c7b1fd3ddf4267f997a4
BLAKE2b-256 5c91dce270bcd861cd41ad08697a01dbf93d52a173db3b72f6dff2776818d0de

See more details on using hashes here.

Provenance

The following attestation bundles were made for polytrader-0.1.5.tar.gz:

Publisher: publish.yml on omidroshani/polytrader

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

File details

Details for the file polytrader-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: polytrader-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for polytrader-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 650f30dd56f0239f589b84d688c6d2692b768fa19a83ab587a8994ede7114d4d
MD5 21999b52e128f56e3b7234a9b33d3175
BLAKE2b-256 04b8b24cfe632643ae9528677b425e3ca32ff1a0ba1bc878e633d4bd4b9cd54d

See more details on using hashes here.

Provenance

The following attestation bundles were made for polytrader-0.1.5-py3-none-any.whl:

Publisher: publish.yml on omidroshani/polytrader

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