Files
trade/data/service/bnkline.ts
T
Rekey 6708abaf56 feat(data/service): add bnkline.ts — Binance REST client K-line wrapper
封装 Client(多交易所 REST 客户端)的 binance 实现,
提供 fetchKlines 服务层函数,复用限流、数据转换、
连续性过滤等既有逻辑,参数顺序更自然(endTime 在 limit 前)。
2026-06-14 18:50:42 +08:00

29 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Client } from "../exchanges/rest";
import type { Kline, KlineInterval } from "../types";
const client = new Client("binance");
/**
* 获取 Binance K 线数据(基于 MainClient REST API)。
*
* 内部复用 Client(多交易所 REST 客户端)的 binance 实现,
* 包含限流、Binance SDK 原生转换、连续性过滤等逻辑。
* 返回本系统标准化 {@link Kline} 数组。
*
* @param symbol - 交易对符号(如 "BTCUSDT"
* @param interval - K 线周期(如 "1h"、"4h"、"1d"
* @param startTime - 起始时间(Unix ms
* @param endTime - 结束时间(Unix ms),可选;不传则拉取到最新
* @param limit - 单次拉取条数,默认 500(最大 1000)
*/
export async function fetchKlines(
symbol: string,
interval: KlineInterval,
startTime: number,
endTime?: number,
limit = 500,
): Promise<Kline[]> {
// Client.fetchKlines 参数顺序:symbol, interval, startTime, limit, endTime
return client.fetchKlines(symbol, interval, startTime, limit, endTime);
}