添加 USDT-M 合约数据支持(配置层 + 清理多余字段)

- 配置层:env.yaml 新增 binance_futures API Key 段,validators + config 同步
- 清理 TradingPair 实体:删除 kline_interval、kline_intervals、kline_synthesis_enabled
- 删除 fetchKlines 系列函数的 interval 参数,硬编码为 1m
- 更新 SQL seed 数据、example、base_rest 接口、types 接口
- 新增 AGENTS/08-boundaries.md 执行纪律
- 新增 PLAN-add-futures-data.md 方案文档
This commit is contained in:
Rekey
2026-06-15 23:24:21 +08:00
parent 6708abaf56
commit b4c7636731
13 changed files with 255 additions and 78 deletions
-26
View File
@@ -22,8 +22,6 @@ import {
import { Exchange } from "./exchange.entity";
import { CommonBaseEntity } from "./common.entity";
import type { KlineInterval } from '../../types';
@Entity("trading_pairs")
@Index(["exchange", "symbol"], { unique: true }) // 同一交易所下 symbol 唯一
@Index(["active"]) // 按激活状态快速筛选
@@ -69,18 +67,6 @@ export class TradingPair extends CommonBaseEntity {
@Column("boolean", { default: true })
active!: boolean;
/** 是否启用 K 线合成(false 时仅采集原始行情,不合成) */
@Column("boolean", { default: true })
kline_synthesis_enabled!: boolean;
/** K 线时间周期 */
@Column("varchar", { length: 100, default: "1m" })
kline_interval!: KlineInterval;
/** K 线合成周期列表(逗号分隔,如 "1m,5m,15m,1h,4h,1d" */
@Column("varchar", { length: 100, default: "1m,5m,15m,1h,4h,1d" })
kline_intervals!: string;
/**
* 历史 K 线最后补全时间(UTC)。
* 记录最近一次 REST 补拉 K 线的结束时间戳,
@@ -96,16 +82,4 @@ export class TradingPair extends CommonBaseEntity {
/** 备注 */
@Column("text", { nullable: true })
notes?: string;
// ============================================================
// 工具方法
// ============================================================
/** 解析 kline_intervals 为周期数组 */
getIntervals(): string[] {
return this.kline_intervals
.split(",")
.map((s) => s.trim())
.filter(Boolean);
}
}
+1 -12
View File
@@ -93,15 +93,6 @@ CREATE TABLE IF NOT EXISTS trading_pairs (
-- 是否激活数据订阅(false 时不采集该交易对行情)
active BOOLEAN NOT NULL DEFAULT TRUE,
-- 是否启用 K 线合成(false 时仅采集原始行情,不合成)
kline_synthesis_enabled BOOLEAN NOT NULL DEFAULT TRUE,
-- 默认 K 线周期
kline_interval VARCHAR(100) NOT NULL DEFAULT '1m',
-- K 线合成周期列表(逗号分隔,如 "1m,5m,15m,1h,4h,1d"
kline_intervals VARCHAR(100) NOT NULL DEFAULT '1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,1d,1w,1mon',
-- 历史 K 线最后补全时间(UTC)。默认 Unix epoch 起始,
-- 新交易对从 epoch 起始时间开始全量补拉。
last_backfill_time TIMESTAMPTZ NOT NULL DEFAULT to_timestamp(0),
@@ -321,7 +312,7 @@ ON CONFLICT (name) DO NOTHING;
-- 默认交易对(仅 Binance 主流 USDT 永续合约,幂等)
INSERT INTO trading_pairs (exchange_id, symbol, base_asset, quote_asset,
price_precision, quantity_precision, kline_interval, kline_intervals, active)
price_precision, quantity_precision, active)
SELECT
e.id,
sym.symbol,
@@ -329,8 +320,6 @@ SELECT
sym.quote,
2, -- price_precisionUSDT 计价通常 2 位小数)
5, -- quantity_precision(数量通常 5 位小数)
'1m',
'1m,5m,15m,30m,1h,4h,1d,1w',
TRUE
FROM exchanges e
CROSS JOIN (