PolyTrader
A Python trading client for Polymarket — the world's largest prediction market.
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.StructwithDecimalprices andStrEnumstatuses - 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.
- Getting Started — Installation, setup, and configuration
- Trading Client — Orders, positions, and balances
- WebSockets — Real-time market and user data
- Binance Integration — Binance streams
- API Reference — Full API documentation
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)
| File | Size | Uploaded | |
|---|---|---|---|
| polytrader-0.1.5.tar.gz | 2.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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