Market data

Backtest with historical OHLCV

A backtest needs clean, dense candles over a long window. Pull historical OHLCV by interval and count, page through the window, and cache it — the reads are cheap C1 so the cost of a full backtest is dominated by your compute, not the API.

开始之前
  • A live API key
  • The token id, interval and date window you want to test

1Pull the historical window

Request the id, interval and limit for each page of history. OHLCV is a C1 read, so pulling a long window stays cheap.

curl "https://api.1st-node.com/v1/market/ohlcv?id=btc&interval=1h&limit=168" \
  -H "Authorization: Bearer sk_live_..."

2Read and normalize the candles

Each row is timestamp, open, high, low, close and volume. Sort by timestamp and check for gaps before you run the strategy over the series.

> { "candles": [
>   [1712000000, 68120.0, 68540.2, 67980.1, 68410.5, 1204.7] ] }

3Cache once, iterate many times

Historical candles are immutable, so pull the window once and cache it locally. A tuning loop then reruns over cached data without spending credits on every pass.

常见问题

How do I cover a multi-month window?

Page the OHLCV endpoint with interval and limit, walking the window in batches. Concatenate the pages in timestamp order into one series.

Will repeated backtests burn credits?

Only the initial pull. OHLCV is a cheap C1 read and historical candles never change, so cache the series and rerun your strategy for free.

继续阅读

充值、拿密钥、上线。

自助开通。支持加密货币或银行卡。按额度计费——重型原语更贵,简单调用很便宜。

获取 API 密钥