Skip to content
All library documents

Paginating Exchange K-Line Requests for Long Historical Series

Article FMZ digest · Author: 发明者量化-小小梦

Summary

The document explains how to retrieve more candlestick bars than an exchange returns in one request. Its JavaScript template divides a requested history into time segments, queries Binance futures K-line endpoints from the present toward the past, and combines the results in chronological order. It maps supported periods to Binance intervals and adjusts request limits for endpoint constraints. A separate update function merges newly returned bars into an existing series, replacing the current bar when needed and appending later bars.

The suggested checks look for duplicate timestamps, gaps between adjacent bars, and agreement with exchange chart data; the article also demonstrates repeatedly updating and plotting the series. The implementation is limited to Binance futures and the listed periods and quote currencies, though the author says it could be extended. It is intended for initial historical loading followed by incremental updates. The document presents checks and example comparisons, not a general guarantee of correctness across exchanges or market data edge cases.

Key ideas

  • Paginate requests over successive time ranges when one exchange response cannot supply the desired history.
  • Convert the requested bar period into an exchange-supported interval before making calls.
  • Merge incremental updates by replacing the latest bar or appending newer bars.
  • Check timestamp uniqueness and continuity, then compare retrieved data with exchange charts.
  • The example implementation supports only specified Binance futures markets and intervals.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.