Get Historical OHLC Candles
binance_get_historical_ohlcFetch historical open, high, low, close (OHLC) candles from Binance for any trading pair and date range. Use it to build price series for technical indicators or backtesting trading strategies.
Instructions
Get historical OHLC (open/high/low/close) candles for a crypto trading pair from Binance, for a given date range and interval.
Use this to build price series for indicator calculation (momentum, moving averages, volatility models like EGARCH) or backtesting. Automatically paginates past Binance's 1000-candle-per-request limit. Caps total candles returned at 2000 per call — if your range would exceed that, the response is truncated and "truncated": true is set; split the request into smaller date ranges if you hit this.
Args:
symbol (string, optional): Trading pair, e.g. "BTCUSDT". Defaults to "BTCUSDT".
interval (string, optional): Candle size — "1h", "4h", "1d", or "1w". Defaults to "1d".
start_date (string, required): Start date, format YYYY-MM-DD. BTCUSDT data begins 2017-08-17.
end_date (string, required): End date, format YYYY-MM-DD.
Returns: { "symbol": string, "interval": string, "requested_start": string, "requested_end": string, "candle_count": number, "truncated": boolean, // true if more candles existed than were returned "note": string (optional), // present if truncated or range predates available data "candles": [ { "open_time": string, // ISO 8601 "open": number, "high": number, "low": number, "close": number, "volume": number, "close_time": string, // ISO 8601 "quote_volume": number, "trade_count": number } ] }
Examples:
Use when: "get me 5 years of daily BTC prices" -> symbol="BTCUSDT", interval="1d", start_date="2020-01-01", end_date="2025-01-01"
Use when: "weekly BTC candles for the last 2 years" -> interval="1w" with an appropriate date range
Don't use when: you just need the current price (use binance_get_current_price)
Error Handling:
Returns "Error: ..." text if dates are malformed, start is after end, or Binance is rate-limiting.
If start_date predates 2017-08-17, the response will include a "note" explaining the series starts later than requested.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | No | Trading pair symbol in Binance format, e.g. "BTCUSDT". Defaults to "BTCUSDT". | BTCUSDT |
| end_date | Yes | End date (inclusive), format YYYY-MM-DD, e.g. "2024-12-31". | |
| interval | No | Candle interval. One of: 1d, 1w, 4h, 1h. Defaults to "1d" (daily), which is what most momentum/volatility backtesting needs. | 1d |
| start_date | Yes | Start date (inclusive), format YYYY-MM-DD, e.g. "2020-01-01". Binance BTCUSDT history begins 2017-08-17; earlier dates return no data. |