fetch_binance_ohlcv
Fetch Binance OHLCV candles and write a backtest-ready CSV, supporting spot and perpetual futures with automatic pagination.
Instructions
Fetch OHLCV candles from Binance public API and write a backtest-ready CSV (header: timestamp,open,high,low,close,volume; timestamp = open time in UNIX ms UTC). Supports spot and usdt_perp (USDT-margined perpetual futures). Requests larger than 1000 bars are paginated automatically. The output path must live inside the MCP cwd unless PINEFORGE_ALLOW_ANYWHERE=1.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Binance symbol, e.g. 'BTCUSDT'. Use binance_symbols to validate. | |
| interval | Yes | Kline interval. Spot supports 1s + 1m..1M; usdt_perp supports 1m..1M (no 1s). | |
| market | No | 'spot' (default) or 'usdt_perp'. | |
| limit | No | Total bars to fetch. Default 1000. Paginated above 1000. | |
| start_time | No | UNIX ms UTC. If unset, derived from end_time/now and limit. | |
| end_time | No | UNIX ms UTC. Defaults to now. | |
| output_path | Yes | Path to write the CSV (will create parent dirs as needed). |