feat: 全链路新增 type 字段支持 + exchange.ts 超时退出优化

- TS: exit 函数统一管理进程退出与 DB 连接关闭;10s 超时 + 异常路径 clearTimeout
- Python: PairType(spot/um/cm) 贯穿 Kline 模型、策略配置、数据查询
- 回测脚本升级: 9策略 × 4币种 × 6时间级别 × 2交易类型
- 新增 generate_report.py 回测报告生成工具
This commit is contained in:
Rekey
2026-06-17 10:01:52 +08:00
parent ebaef5042e
commit 626acb20d3
13 changed files with 42394 additions and 5129 deletions
+1
View File
@@ -29,6 +29,7 @@ class StrategyConfig(BaseModel):
name: str = ""
symbol: str = ""
exchange: str = "binance"
type: str = "spot" # 交易对类型:spot / um / cm
enabled: bool = True
max_position_pct: float = 0.1 # 最大仓位占总资金比例
stop_loss_pct: Optional[float] = None # 止损百分比
+10
View File
@@ -16,6 +16,13 @@ from pydantic import BaseModel, Field, field_validator
KlineInterval = Literal["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "1d", "1w", "1mon"]
# ============================================================
# 交易对类型
# ============================================================
PairType = Literal["spot", "um", "cm"]
"""交易对类型,与 TS data/types/kline.ts 的 PairType 对齐"""
# ============================================================
# 行情数据模型
@@ -125,6 +132,9 @@ class Kline(BaseModel):
interval: KlineInterval
"""K 线周期"""
pair_type: PairType = Field(default="spot", alias="type")
"""交易对类型(spot / um / cm),与 TS Kline.type 对齐"""
# 时间
open_time: float = Field(alias="openTime")
"""开盘时间(Unix 毫秒)"""