Polymarket trading toolkit.
pmtrader/ Python SDK + CLI
pmproxy/ Rust reverse proxy (Lambda live; EC2 binary as fallback)
pmengine/ Rust HFT trading engine
pmstrat/ Python strategy DSL + backtesting + transpiler to Rust
flowchart LR
subgraph Clients
CLI["pmt CLI"]
BOT["Bots / Scripts"]
end
subgraph PMT["pmtrader (Python)"]
API["PolymarketAPI"]
AUTH["Auth & Signing"]
end
subgraph STRATDSL["pmstrat (Python)"]
DSL["Strategy DSL"]
TRANS["Transpiler"]
end
subgraph ENGINE["pmengine (Rust)"]
STRAT["Strategy Runtime"]
ORDER["Order Manager"]
RISK["Risk Manager"]
end
DSL --> TRANS
TRANS -->|"generates"| STRAT
CLI --> PMT
BOT --> PMT
PMT --> DECIDE{"PMPROXY_URL?"}
subgraph PROXY["pmproxy (Rust)"]
LAMBDA["Lambda (eu-west-1)"]
end
DECIDE -->|set| PROXY
DECIDE -->|unset| POLY
subgraph POLY["Polymarket"]
CLOB["CLOB API"]
GAMMA["Gamma API"]
RPC["Polygon RPC"]
end
PROXY --> POLY
ENGINE --> POLY
cd pmtrader && uv syncpmt --help # list subcommands
# Symmetric buy/sell: REF is a polymarket URL/slug OR numeric token id.
pmt buy https://polymarket.com/event/btc-updown-4h-1779825600 down --amount $910
pmt sell URL no --amount $50 --match Trump # URL ref + outcome
pmt buy 14658893069672317885... --price 0.92 --size 217 # token ref + explicit limit
pmt positions --orders # portfolio + open orders + exposure
pmt pnl # realized 1d/7d/30d/all + unrealized
pmt rewards --days 7 # REWARD + YIELD income
pmt search pandemic # cross-market search
pmt engine status # local engine snapshot
pmt scan cliff # opportunity scannersSee pmtrader/README.md for the full CLI reference.
# .env (for trading)
PM_PRIVATE_KEY=0x...
PM_FUNDER_ADDRESS=0x...
PM_SIGNATURE_TYPE=1 # 0=EOA, 1=Poly Proxy, 2=EIP-1271
# pmproxy (required to trade from a geoblocked region)
PMPROXY_URL=https://<...>.lambda-url.eu-west-1.on.aws
PMPROXY_USERNAME=...
PMPROXY_PASSWORD=...from polymarket import PolymarketAPI
api = PolymarketAPI()
api.place("buy", token=..., price=0.93, size=217)
api.flip(token=..., buy_price=0.09, sell_price=0.10, size=850)
api.get_positions()
api.search_markets("pandemic")cd pmproxy && cargo build --release --features ec2
./target/release/pmproxyRoutes /clob/*, /gamma/*, /chain/* to Polymarket APIs.
See pmproxy/README.md.
cd pmengine && cargo build --release --features ec2
./target/release/pmengine --dry-run# .env
PMENGINE_PRIVATE_KEY=0x...
PMENGINE_MAX_POSITION_SIZE=1000
PMENGINE_MAX_TOTAL_EXPOSURE=5000
PMENGINE_TICK_INTERVAL_MS=1000cd pmstrat && uv sync
uv run pmstratStrategy DSL and backtesting framework. Define strategies in a constrained Python subset using the @strategy decorator, backtest locally, then transpile to Rust for execution by pmengine.
Python Strategy (pmstrat DSL)
↓ transpile
Rust Strategy Code
↓ compile into
pmengine binary
↓ execute
Polymarket (production)
cd pmtrader && uv run pytest # Python SDK tests
cd pmstrat && uv run pytest # Strategy tests
cd pmproxy && cargo test # Proxy tests
cd pmengine && cargo test # Engine tests