1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! # Polymarket Prediction Markets Connector
//!
//! Category: prediction/polymarket
//! Type: Prediction Market (CLOB-based probability trading)
//!
//! ## Overview
//!
//! Polymarket is a prediction market platform where users trade on the
//! probability of real-world events. Prices represent probabilities (0.0-1.0).
//!
//! ## APIs
//!
//! | API | URL | Purpose |
//! |-----|-----|---------|
//! | CLOB | `https://clob.polymarket.com` | Order books, prices, markets |
//! | Gamma | `https://gamma-api.polymarket.com` | Events, enhanced market metadata |
//! | Data | `https://data-api.polymarket.com` | User positions, trades |
//! | WS CLOB | `wss://ws-subscriptions-clob.polymarket.com/ws/market` | Real-time data |
//!
//! ## Key Concepts
//!
//! - `condition_id` — 0x-prefixed hex string identifying a market on-chain
//! - `token_id` — numeric string identifying a YES or NO outcome token
//! - Prices are probabilities: 0.65 = 65% chance the event occurs
//!
//! ## Usage
//!
//! ```ignore
//! use connectors_v5::prediction::polymarket::PolymarketConnector;
//! use connectors_v5::core::traits::MarketData;
//! use connectors_v5::core::types::{AccountType, Symbol};
//!
//! // Create public connector
//! let connector = PolymarketConnector::public();
//!
//! // Ping to check connectivity
//! connector.ping().await?;
//!
//! // Get all active markets as SymbolInfo
//! let symbols = connector.get_exchange_info(AccountType::Spot).await?;
//!
//! // Get price for a specific market (condition_id as symbol.base)
//! let symbol = Symbol::new("0xABCDEF1234...", "USDC");
//! let price = connector.get_price(symbol, AccountType::Spot).await?;
//! println!("YES probability: {:.1}%", price * 100.0);
//!
//! // Get klines (price history)
//! let klines = connector.get_klines(symbol, "1h", Some(100), AccountType::Spot, None).await?;
//! ```
//!
//! ## WebSocket
//!
//! ```ignore
//! use connectors_v5::prediction::polymarket::{ClobWebSocket, WsEvent};
//!
//! let token_ids = vec!["TOKEN_ID".to_string()];
//! let mut ws = ClobWebSocket::new(token_ids, false);
//!
//! ws.connect().await?;
//!
//! while let Ok(Some(event)) = ws.recv().await {
//! match event {
//! WsEvent::LastTradePrice(trade) => println!("Price: {}", trade.price),
//! _ => {}
//! }
//! }
//! ```
// Public API
pub use ;
pub use ;
pub use ;
pub use PolymarketConnector;
pub use ;