Execution utilities for Polymarket CLOB: stop-loss, take-profit, redeem, position reconciliation, and order lifecycle
Project description
polymarket-execution
Battle-tested execution utilities for Polymarket CLOB v2: stop-loss, take-profit, redeem, position reconciliation, order lifecycle, and recovery layers for masked fills.
Built on top of py-clob-client-v2. Designed to be the missing layer between the raw CLOB primitives and a production trading bot.
Status: Early development (v0.1.x alpha). API may change before 1.0.
Why this exists
The Polymarket CLOB gives you primitives like create_and_post_order and cancel_order, but doesn't help with the things you actually need to run a bot in production:
- Stop-loss / take-profit execution — CLOB has no native trigger orders
- Redeeming resolved positions — claim winnings via web3 (with the USDC.e → pUSD wrap dance that V2 introduced)
- Position reconciliation — keep CLOB and on-chain state in sync
- Order lifecycle — retry, replace, and clean up stale orders
- Recovery layers — detect masked fills when network errors / status timeouts / balance locks hide a successful order
This library provides those primitives, with no opinions about your trading strategy.
Install
pip install polymarket-execution
Optional extras:
pip install polymarket-execution[markets] # adds polymarket-apis for category-filtered listing/search
pip install polymarket-execution[dev] # pytest, ruff, mypy
Crypto up/down market discovery (BTC/ETH/SOL/XRP at 5m/15m/1h windows) works out of the box — the
[markets]extra is only needed for general listing/search across categories.
Quick start: discover current crypto markets
Available now. Native slug-based lookup, no
[markets]extra needed.
from polymarket_execution.markets import discover_current_markets
markets = discover_current_markets(window="5m") # btc, eth, sol, xrp by default
for m in markets:
print(m, "->", m.polymarket_url)
Quick start: redeem resolved positions
Preview API. Implementation lands in v0.1.0; the snippet below shows the target shape.
from py_clob_client_v2 import ClobClient
from polymarket_execution.redeem import RedeemClient
client = ClobClient(host="https://clob.polymarket.com", chain_id=137, key=PRIVATE_KEY, signature_type=2, funder=SAFE_ADDRESS)
redeemer = RedeemClient(clob_client=client, web3_rpc_url=POLYGON_RPC, safe_address=SAFE_ADDRESS)
result = redeemer.auto_redeem_all() # also wraps USDC.e -> pUSD afterwards
print(result.redeemed_markets, result.wrap_tx_hash)
Quick start: stop-loss
Preview API. Implementation lands in v0.3.0; the snippet below shows the target shape.
from polymarket_execution.triggers import StopLossMonitor
from polymarket_execution.price_reference import use_mid_price
monitor = StopLossMonitor(clob_client=client, price_source=use_mid_price)
monitor.add_stop(token_id="0x...", trigger_price=0.45, size=100)
await monitor.run()
Modules
| Module | Purpose |
|---|---|
redeem |
Claim USDC from resolved positions via web3 (with V2 USDC.e → pUSD wrap) |
triggers.stop_loss |
Monitor positions and execute market orders on trigger |
triggers.take_profit |
Monitor PnL and execute market orders on profit target |
orders.place |
Place orders with sane defaults |
orders.fills |
Get true VWAP fill price via get_trades (fixes a critical PnL bug) |
recovery |
5 recovery layers for masked fills (network/status/balance/matched_orders/suspect_drop) |
position |
Reconcile CLOB and on-chain positions |
markets.crypto |
Native slug-based discovery for crypto up/down markets (no extra) |
markets.general |
List/search arbitrary markets (requires [markets] extra) |
order_lifecycle |
Retry, replace, and clean up stale orders |
price_feed.chainlink_rtds |
Polymarket-aligned ChainLink price feed via WebSocket |
CLI
polymarket-execution redeem auto # redeem all resolved positions
polymarket-execution markets crypto --window 5m # current crypto markets (no extra)
polymarket-execution markets crypto --symbol btc # single symbol
polymarket-execution markets list # general listing (requires [markets])
polymarket-execution stop-loss watch # interactive stop-loss monitor
polymarket-execution take-profit watch # interactive take-profit monitor
polymarket-execution position reconcile # CLOB vs chain drift report
Run polymarket-execution --help for the full command tree.
What this is NOT
- A trading framework. You decide when, what, and how much to trade.
- A strategy library. No signals, no parameters, no backtesting.
- A replacement for
py-clob-client-v2. It plugs in on top.
License
Sponsor
If this saves you time in production, consider sponsoring.
Project details
Release history Release notifications | RSS feed
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 polymarket_execution-0.1.0a0.tar.gz.
File metadata
- Download URL: polymarket_execution-0.1.0a0.tar.gz
- Upload date:
- Size: 35.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6776ee1b42030aa578e3719180cb8939948404fe54041c7e10c59d7bf05b1a1
|
|
| MD5 |
c284f27c2f99b68a78029d2277ada2fb
|
|
| BLAKE2b-256 |
da4b6cb53703209a77af080093b6415845bae9e684c91ae80a4da3671471e294
|
Provenance
The following attestation bundles were made for polymarket_execution-0.1.0a0.tar.gz:
Publisher:
publish.yml on eduardodoege/polymarket-execution
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polymarket_execution-0.1.0a0.tar.gz -
Subject digest:
c6776ee1b42030aa578e3719180cb8939948404fe54041c7e10c59d7bf05b1a1 - Sigstore transparency entry: 1411720111
- Sigstore integration time:
-
Permalink:
eduardodoege/polymarket-execution@dead7d2c4fa3e41cd50b37e485545c83ad50dea2 -
Branch / Tag:
refs/tags/v0.1.0a0 - Owner: https://github.com/eduardodoege
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dead7d2c4fa3e41cd50b37e485545c83ad50dea2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file polymarket_execution-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: polymarket_execution-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa62924abab88700d79ddbc80253816367b5140077ed24280fb6b95ce03690c9
|
|
| MD5 |
e858be27bc7bcbee88e402fe340f74c2
|
|
| BLAKE2b-256 |
85c58fe51f495f549bffd77c960363ca5e468d5a891a90478baac1f4b832e5be
|
Provenance
The following attestation bundles were made for polymarket_execution-0.1.0a0-py3-none-any.whl:
Publisher:
publish.yml on eduardodoege/polymarket-execution
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polymarket_execution-0.1.0a0-py3-none-any.whl -
Subject digest:
fa62924abab88700d79ddbc80253816367b5140077ed24280fb6b95ce03690c9 - Sigstore transparency entry: 1411720205
- Sigstore integration time:
-
Permalink:
eduardodoege/polymarket-execution@dead7d2c4fa3e41cd50b37e485545c83ad50dea2 -
Branch / Tag:
refs/tags/v0.1.0a0 - Owner: https://github.com/eduardodoege
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dead7d2c4fa3e41cd50b37e485545c83ad50dea2 -
Trigger Event:
push
-
Statement type: