Python trading client for Polymarket
Project description
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.
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf1fdfa81107c699aa287a789cc77bebeef44a9142bff9794292a3c7faabe79b
|
|
| MD5 |
9251d5826f26c7b1fd3ddf4267f997a4
|
|
| BLAKE2b-256 |
5c91dce270bcd861cd41ad08697a01dbf93d52a173db3b72f6dff2776818d0de
|
Provenance
The following attestation bundles were made for polytrader-0.1.5.tar.gz:
Publisher:
publish.yml on omidroshani/polytrader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polytrader-0.1.5.tar.gz -
Subject digest:
bf1fdfa81107c699aa287a789cc77bebeef44a9142bff9794292a3c7faabe79b - Sigstore transparency entry: 1125116359
- Sigstore integration time:
-
Permalink:
omidroshani/polytrader@2891a84a10d2d080ae3d6cea66780a6450c63ecd -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/omidroshani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2891a84a10d2d080ae3d6cea66780a6450c63ecd -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
650f30dd56f0239f589b84d688c6d2692b768fa19a83ab587a8994ede7114d4d
|
|
| MD5 |
21999b52e128f56e3b7234a9b33d3175
|
|
| BLAKE2b-256 |
04b8b24cfe632643ae9528677b425e3ca32ff1a0ba1bc878e633d4bd4b9cd54d
|
Provenance
The following attestation bundles were made for polytrader-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on omidroshani/polytrader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polytrader-0.1.5-py3-none-any.whl -
Subject digest:
650f30dd56f0239f589b84d688c6d2692b768fa19a83ab587a8994ede7114d4d - Sigstore transparency entry: 1125116399
- Sigstore integration time:
-
Permalink:
omidroshani/polytrader@2891a84a10d2d080ae3d6cea66780a6450c63ecd -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/omidroshani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2891a84a10d2d080ae3d6cea66780a6450c63ecd -
Trigger Event:
release
-
Statement type: