polymarket-hft
A high-frequency trading (HFT) system for Polymarket with built-in API clients and CLI.
Features
- 🚀 High Performance - Built on Tokio for high-performance async operations
- 📊 Built-in APIs - Data API, Gamma, CLOB, and RTDS clients available
- 🔌 Real-Time Streaming - WebSocket support for RTDS real-time data feeds
- 🔒 Type-Safe - Strongly typed API with comprehensive error handling
- 🔄 Auto Retry - Built-in exponential backoff retry for transient failures
- 🛠️ CLI Tool - Command-line interface for quick API access and testing
- ⚡ Low Latency - Optimized for trading scenarios requiring fast execution
- 📚 Well-Documented - Extensive documentation and examples
Documentation
| Document | Description |
|---|---|
| Library Guide | How to use the SDK as a Rust library |
| CLI Guide | How to use the command-line interface |
| API Docs | Full API documentation |
Quick Start
As a Library
use Client;
async
👉 See Library Guide for more details.
As a CLI
# Check API health
# Get user's traded markets count
# List latest Gamma markets
👉 See CLI Guide for more details.
Supported APIs
| API | Status | Description |
|---|---|---|
| Data API | ✅ | Health, holders, value, traded, open interest, live volume, positions, trades, activity |
| Gamma Markets | ✅ | Sports, events, markets, tags, series, comments, search |
| CLOB | ✅ | Public REST endpoints available; private/WS pending |
| CLOB WebSocket | ✅ | Real-time orderbook updates, trade streams, user events |
| RTDS | ✅ | Real-time data streaming (prices, trades, orderbook, comments) |
Installation
[]
= "0.0.5"
Architecture
polymarket-hft/
├── src/
│ ├── client/
│ │ ├── data/ # Data API client
│ │ ├── clob/ # CLOB REST API client
│ │ │ └── ws/ # CLOB WebSocket client
│ │ ├── gamma/ # Gamma Markets API client
│ │ ├── rtds/ # RTDS WebSocket client
│ │ └── http.rs # Shared HTTP client with retry middleware
│ ├── cli/ # CLI command implementations
│ └── main.rs # CLI entry point
Development Status
🚧 This project is in active development.
Versioning Policy
| Version | Stability | Description |
|---|---|---|
| 0.0.x | ⚠️ Early Development | Breaking changes expected. APIs are experimental and not fully validated. Use for exploration only. |
| 0.1.x | 🔄 Beta | Client APIs stabilized with no breaking changes within minor versions. Trading strategies remain experimental and may have breaking changes. |
| 1.0.x | ✅ Stable | Full API stability. Trading strategies validated and stable. |
[!CAUTION] Current
0.0.xversions are in early development. Expect breaking changes between releases. Do not use in production trading systems.
Current Status
- ✅ Project structure and module organization
- ✅ Data API client with 10 endpoints:
health- API health checkget_market_top_holders- Get top holders for marketsget_user_portfolio_value- Get total value of user's positionsget_user_traded_markets- Get user's traded markets countget_open_interest- Get open interest for marketsget_event_live_volume- Get live volume for an eventget_user_positions- Get current positions for a userget_user_closed_positions- Get closed positions for a userget_user_activity- Get on-chain activity for a userget_trades- Get trades for a user or markets
- ✅ CLI tool for Data API
- ✅ CI/CD pipeline (GitHub Actions)
Roadmap
Implement Data API endpoints✅- Implement CLOB REST API endpoints
Implement CLOB WebSocket connectivity✅Implement Gamma Markets API endpoints✅Implement RTDS streaming✅- Add HFT trading strategies framework
- Add comprehensive integration tests
- Publish to crates.io
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
# Clone the repository
# Build the project
# Run tests
# Run the CLI
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This is an unofficial SDK and is not affiliated with Polymarket. Use at your own risk. This software is intended for educational and research purposes.