Skip to main content

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.

Release files for polytrader 0.1.5

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

Source distribution (sdist)

Source distribution for polytrader 0.1.5
File Size Uploaded
polytrader-0.1.5.tar.gz 2.0 MB Details

Built distribution (wheel)

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

Total release size: 2.0 MB

Release files / polytrader-0.1.5.tar.gz

Download URL polytrader-0.1.5.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
bf1fdfa81107c699aa287a789cc77bebeef44a9142bff9794292a3c7faabe79b
BLAKE2b-256 checksum
How to use checksums
5c91dce270bcd861cd41ad08697a01dbf93d52a173db3b72f6dff2776818d0de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 18, 2026.

Transparency log

Release files / polytrader-0.1.5-py3-none-any.whl

Download URL polytrader-0.1.5-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
650f30dd56f0239f589b84d688c6d2692b768fa19a83ab587a8994ede7114d4d
BLAKE2b-256 checksum
How to use checksums
04b8b24cfe632643ae9528677b425e3ca32ff1a0ba1bc878e633d4bd4b9cd54d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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