Overview
Polymarket Exchange provides multiple methods for obtaining candlestick (OHLC - Open, High, Low, Close) data for market analysis and charting applications.Method 1: Pre-Aggregated Statistics (Recommended)
Use the REST API’s trade statistics endpoint to get pre-calculated OHLC data:- Server-side aggregation (faster, more efficient)
- Ready-to-use candlestick data
- Configurable time intervals
- No client-side computation required
1m- 1 minute5m- 5 minutes15m- 15 minutes1h- 1 hour4h- 4 hours1d- 1 day
Method 2: Manual Aggregation from Trade Data
Query individual trades and calculate OHLC values client-side:Aggregation Logic
- Query trades for the desired time range
- Group trades by your chosen interval (e.g., 5min, 1h, 1d)
- For each interval, calculate:
| Metric | Calculation |
|---|---|
| Open | First trade price in the interval |
| High | Maximum trade price in the interval |
| Low | Minimum trade price in the interval |
| Close | Last trade price in the interval |
| Volume | Sum of quantities traded in the interval |
| Notional | Sum of (price × quantity) for all trades |
Python Example
- Custom aggregation logic needed
- Non-standard time intervals
- Additional trade metadata required
- Complex filtering or weighting logic
Method 3: Real-Time Streaming
Subscribe to market data via gRPC to build live candlestick charts that update as trades occur.Subscribe to Market Data
Building Real-Time Candles
- Real-time price updates
- Last trade price and volume
- Aggregated statistics (cumulative volume, notional traded)
- Best bid/offer data
- Live trading dashboards
- Real-time candlestick charts
- Automated trading strategies
- Market monitoring systems
Choosing the Right Method
| Method | Best For | Latency | Complexity |
|---|---|---|---|
| Pre-Aggregated | Historical analysis, standard intervals | Low | Low |
| Manual Aggregation | Custom intervals, special calculations | Medium | Medium |
| Real-Time Streaming | Live charts, automated trading | Real-time | High |
Best Practices
Time Zones
All timestamps are in UTC. Ensure your client handles timezone conversion appropriately:Price Scaling
Prices in the API use aprice_scale multiplier. Check the instrument’s reference data:
Data Gaps
Handle gaps in data gracefully:- Pre-aggregated: Missing intervals indicate no trades occurred
- Manual: Empty intervals should show previous close as O/H/L/C
- Streaming: Implement reconnection logic for dropped connections
Caching
For historical data:- Cache pre-aggregated candles locally
- Only query new intervals since last update
- Use
start_timefilters to avoid redundant data