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
+22 -10
View File
@@ -171,6 +171,26 @@ export const DEFAULT_REST_CONFIG: RestClientConfig = {
defaultLimit: 500,
};
// ============================================================
// fetchKlines 参数对象
// ============================================================
/** fetchKlines 统一参数对象 */
export interface FetchKlinesParams {
/** 交易所标识(如 "binance" */
exchange: string;
/** 交易对符号(如 BTCUSDT */
symbol: string;
/** 交易对类型(spot / um / cm */
type: PairType;
/** 起始时间(Unix ms */
startTime: number;
/** 单次拉取条数,默认取自 config.defaultLimit */
limit?: number;
/** 结束时间(Unix ms),可选 */
endTime?: number;
}
// ============================================================
// 适配器配置(含 WebSocket 重连)
// ============================================================
@@ -235,18 +255,10 @@ export interface MarketDataFeed {
/**
* REST 拉取历史 K 线(用于补齐缺失数据或回测)。
*
* @param symbol - 交易对符号
* @param startTime - 起始时间(Unix ms
* @param endTime - 结束时间(Unix ms
* @param limit - 最大返回条数(默认 500)
* @param params - fetchKlines 统一参数对象
* @returns 标准化 K 线数组,按时间升序
*/
fetchKlines(
symbol: string,
startTime: number,
endTime: number,
limit?: number,
): Promise<Kline[]>;
fetchKlines(params: FetchKlinesParams): Promise<Kline[]>;
/**
* 获取交易所交易对信息(用于自动注册到 trading_pairs 表)。