Files
trade/data/exchanges/index.ts
T
Rekey 705a2f6ea0 feat: 接入 USDT-M 合约数据 — type 字段方案
- PairType 定义移至 types/kline.ts (spot/um/cm)
- Kline 接口新增 type 字段,全链路透传
- klines 5列复合主键 (exchange, symbol, type, interval, time)
- 拆出 BinanceFuturesRestClient (USDMClient)
- exchanges/index.ts 注册 binance_futures
- trading_pairs 唯一约束加 type,种子数据加合约对
- 12个连续聚合视图 SELECT/GROUP BY/INDEX 加 type
- 清理 bnkline.ts 废弃代码和 pair.ts 空函数
2026-06-16 18:39:40 +08:00

34 lines
1.1 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 { BaseRestClient } from "./base";
import { BinanceRestClient, BinanceFuturesRestClient } from "./binance/rest";
/** 交易所 ID 到 RestClient 构造器的注册表 */
const registry: Record<string, () => BaseRestClient> = {
binance: () => new BinanceRestClient(),
binance_futures: () => new BinanceFuturesRestClient(),
};
/**
* 创建交易所 REST 客户端。
*
* 根据交易所 ID 返回对应的 RestClient 实例,
* 外部无需感知具体子类。
*
* @param exchangeId - 交易所标识(如 "binance"
* @returns 对应交易所的 RestClient 实例
* @throws 如果 exchangeId 未注册
*/
export function createRestClient(exchangeId: string): BaseRestClient {
const factory = registry[exchangeId];
if (!factory) {
const supported = Object.keys(registry).join(", ");
throw new Error(
`[exchanges] 不支持的交易所: "${exchangeId}",当前支持: ${supported}`,
);
}
return factory();
}
export { BaseRestClient } from "./base";
export { BinanceRestClient, BinanceFuturesRestClient } from "./binance/rest";
export { KLINE_INTERVAL_MS } from "./constants";