Skip to content

feat: add Polymarket trading support via Turbine API proxy#34

Open
ten-nex wants to merge 4 commits intomainfrom
feat/polymarket-sdk
Open

feat: add Polymarket trading support via Turbine API proxy#34
ten-nex wants to merge 4 commits intomainfrom
feat/polymarket-sdk

Conversation

@ten-nex
Copy link
Copy Markdown
Contributor

@ten-nex ten-nex commented Mar 24, 2026

What

Adds PolymarketClient to the SDK so users can trade on Polymarket through Turbine's API proxy. Companion to turbine-clob PR #281.

How it works

  • All requests route through Turbine API with ?polymarket=true query param
  • Polymarket credentials passed via X-Polymarket-* headers per-request
  • Order signing happens client-side via py_clob_client — Turbine never sees private keys
  • Non-custodial, stateless, same pattern as the Go backend

What's included

  • turbine_client/polymarket.pyPolymarketClient class (auth, markets, orderbook, orders, positions)
  • examples/polymarket_bot.py — Complete example bot with market scanning, order placement, position tracking
  • tests/test_polymarket.py — 23 unit tests, all passing
  • pyproject.tomlpy-clob-client as optional [polymarket] extra
  • turbine_client/__init__.py — Export added

Testing

pytest tests/test_polymarket.py -v  # 23/23 passing

Depends on: ojo-network/turbine-clob#281

ten-nex added 4 commits March 24, 2026 09:32
- Add PolymarketClient in turbine_client/polymarket.py with full API coverage:
  authenticate, derive_api_key, get_markets, get_orderbook, create_order,
  cancel_order, get_open_orders, get_positions
- All requests routed through Turbine with ?polymarket=true query param
- Authenticated requests use X-Polymarket-* headers (per-request, never stored)
- Add optional dependency: polymarket = ["py-clob-client>=0.18.0"]
- Export PolymarketClient from turbine_client/__init__.py
- Add examples/polymarket_bot.py with market scanning, order placement,
  position tracking, graceful shutdown
- Add tests/test_polymarket.py with 23 unit tests covering headers, params,
  order payloads, auth flow, error handling, URL construction
- polymarket_auth.py: sign_clob_auth_message() and get_polymarket_credentials()
  handle the full EIP-712 auth flow so users don't need to manually obtain keys
- create-polymarket-bot skill: Claude Code skill for generating Polymarket bots
- Updated __init__.py exports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant