refactor(exchanges): fetchKlines 改为 params 对象签名,新增 type/exchange 参数

- 新增 FetchKlinesParams 接口统一 fetchKlines 参数(exchange/type/symbol/startTime/limit/endTime)
- BaseRestClient 抽象方法 + MarketDataFeed 接口改为 params 对象签名
- BinanceRestClient / BinanceFuturesRestClient 由调用方传入 type,不再硬编码 spot/um
- index.ts 新增静态 fetchKlines(params) 便捷函数,按 exchange+type 自动路由
- exchange.ts / bnkline.ts 调用方适配新签名
- 初始化 SQL 补充 BNBUSDT/SOLUSDT 合约交易对
This commit is contained in:
Rekey
2026-06-16 19:02:16 +08:00
parent 705a2f6ea0
commit ebaef5042e
7 changed files with 87 additions and 56 deletions
+10 -6
View File
@@ -1,13 +1,11 @@
import { createRestClient } from "../exchanges";
import { fetchKlines as fetchKlinesFromExchange } from "../exchanges";
import type { Kline } from "../types";
const client = createRestClient("binance");
/**
* 获取 Binance 1m K 线数据(基于 MainClient REST API)。
*
* 内部复用 Client(多交易所 REST 客户端)的 binance 实现
* 包含限流、Binance SDK 原生转换、连续性过滤等逻辑。
* 内部复用 fetchKlines 静态方法,自动路由到正确的交易所客户端
* 包含限流、Binance SDK 原生转换等逻辑。
* 返回本系统标准化 {@link Kline} 数组。
*
* @param symbol - 交易对符号(如 "BTCUSDT"
@@ -19,5 +17,11 @@ export async function fetchKlines(
startTime: number,
limit = 500,
): Promise<Kline[]> {
return client.fetchKlines(symbol, startTime, limit);
return fetchKlinesFromExchange({
exchange: 'binance',
type: 'spot',
symbol,
startTime,
limit,
});
}