Rekey
|
9351dec226
|
refactor: migrate API keys to config, extend Kline intervals, add DB extensions
Security:
- Move hardcoded Binance API key/secret from rest.ts to env.yaml (exchange config segment)
- Add ExchangeConfig validation in config/validators.ts
- Export typed exchange config from config/index.ts
- Update AGENTS/07-caveats.md to reflect the new policy
Kline intervals (add 3m / 2h / 6h / 8h / 1mon):
- TypeScript: update KlineInterval type, KLINE_INTERVAL_MS mapping, build_aggregates_sql refresh chain
- Python: sync KlineInterval Literal type, INTERVAL_TO_TABLE and INTERVAL_MS mappings, db_test table list
- SQL: add 5 continuous aggregate materialized views (klines_3m/2h/6h/8h/1mon) with indexes
- SQL: extend default kline_intervals in trading_pairs table
- SQL: add cross-sectional query indexes for klines_1d and klines_1w
DB:
- Enable pg_prewarm extension (backtest warmup)
- Enable pg_stat_statements extension (slow query monitoring)
Other:
- data/run/exchange.ts: graceful pgsql shutdown after backfill completes
- Config path: load from data/env.yaml (symlink) instead of project root
|
2026-06-14 18:45:01 +08:00 |
|
Rekey
|
0cd2cbbb79
|
feat(engine): 新增 2h/6h 与 1h 策略对比回测
- comparison_2h_6h: 9 策略 × 4 币种 × 2 周期 × 4 数据量 = 288 次回测
- 包含海龟、超级趋势、MACD、布林收缩、三均线、RSI 回归、
ATR 波动率突破、EMA 多空、牛熊自适应
- 结论:6h 夏普显著优于 2h(69% 组合),ATR 策略霸榜
- 自动生成 Markdown 回测报告
- vol_break_1h_6h: ATR 波动率突破 × 1h/2h/4h/6h 近半年对比
|
2026-06-14 00:15:16 +08:00 |
|
Rekey
|
edc50e8809
|
feat: 新增2h/6h时间框架支持,策略重构为增量指标计算
- 数据层: build_aggregates_sql 新增 2h/6h 聚合视图,默认起始时间调整为 2017-05
- 模型层: KlineInterval 类型扩展 2h/6h,DataService 新增对应表名和毫秒映射
- 指标层: 新增 incremental.py 增量指标模块 (EmaInc/AtrInc/RsiInc/BbInc),O(1) per bar
- 策略重构: long_short.py 和 regime_all.py 从批量 ema/atr 迁移至增量指标,避免每 bar 重复全量计算
- regime 探测器: RegimeDetector3 改为增量 EMA200,detect() 接口简化
- 回测扩展: regime_timeframe_comparison 从 4h/1d 扩展至 2h/4h/6h/1d
- 新增示例: multi_strategy_report, vol_break_compare/periods, intraday_explore, top3_trades 等分析脚本
|
2026-06-13 19:30:25 +08:00 |
|
Rekey
|
b5cdb41993
|
chore: 更新 README 架构文档与数据库测试脚本
- README.md: 更新数据层 Node.js→Bun,common→engine/common,同步目录树结构
- db_test.py: TimescaleDB 数据库连接与基础查询测试脚本
|
2026-06-12 10:27:11 +08:00 |
|
Rekey
|
515e61c517
|
feat(engine): 添加策略示例集(18 个 Demo)
- backtest_demo.py: 回测基础演示
- strategy_simple.py / three_ema.py / long_short.py: 基础策略(双均线/三均线/多空)
- strategy_optimize*.py (3 版本): 参数优化示例(网格搜索/贝叶斯/遗传算法)
- multi_tf_*.py (4 版本): 多时间框架策略(EMA200/多周期共振/混合信号)
- regime_*.py (4 版本): 市场状态检测(趋势/震荡/波动率区间/全状态)
- cross_section.py: 截面多品种策略
- factor_demo.py: 多因子模型演示
- strategy_battle.py / strategy_more.py: 策略对比与组合
- full_cycle.py: 全流程演示(数据→回测→分析)
- data.py: 数据读取示例
|
2026-06-12 10:27:04 +08:00 |
|
Rekey
|
4da520c14b
|
feat(engine): 添加事件驱动回测引擎
- backtest/engine.py: 事件驱动回测引擎核心,支持 K 线推进/订单撮合/权益曲线
- backtest/models.py: 回测数据模型(订单/成交/持仓/账户快照)
- backtest/README.md: 回测模块使用说明
- backtest/STRATEGY.md: 策略开发指南与最佳实践
- backtest/TIMEFRAME_COMPARISON*.md: 多周期回测对比分析报告
|
2026-06-12 10:26:53 +08:00 |
|
Rekey
|
212f6fedad
|
feat(engine): 添加数据服务层与技术指标库
- data/service.py: 数据拉取服务,从 TimescaleDB 读取 K 线/Ticker 等行情数据
- indicators/momentum.py: 动量类指标(RSI/MACD/Stochastic 等)
- indicators/trend.py: 趋势类指标(EMA/SMA/ADX/SuperTrend 等)
- indicators/volatility.py: 波动率指标(Bollinger/ATR/Keltner 等)
- indicators/volume.py: 成交量指标(OBV/VWAP/MFI 等)
|
2026-06-12 10:26:45 +08:00 |
|
Rekey
|
039bfb5075
|
feat(engine): 添加核心基础设施 — engine/common 模块
- engine/__init__.py: 包入口,导出 Kline/KlineInterval/OrderBook/Ticker/Trade
- common/base.py: BaseStrategy 抽象基类,定义 on_kline/on_ticker/on_orderbook 回调
- common/models.py: Pydantic 数据模型,与 TS 侧 types 字段对齐,支持字段校验
- common/config.py: 全局配置加载(YAML),统一 engine/env.yaml 读取
- common/logger.py: 结构化日志,支持 JSON/pretty print 输出
|
2026-06-12 10:26:37 +08:00 |
|
Rekey
|
4d66a86234
|
docs: 添加项目规范与引擎设计文档
- AGENTS.md: AI Agent 规则,定义项目运行环境、架构约定、常用命令
- ENGINE.md: Python 引擎架构设计文档,涵盖策略管理、信号总线、回测引擎等模块设计
|
2026-06-12 10:26:30 +08:00 |
|
Rekey
|
904728266f
|
refactor(engine): 移除旧 Python 项目代码,替换为统一 YAML 环境配置
- 删除 engine 目录下原有的 Python 项目文件(config、data、example、pyproject.toml 等)
- 新增 engine/env.yaml 统一环境配置文件,供 data(TS)和 Python 模块共用
- 实现配置与代码解耦,后续 engine 模块将基于 env.yaml 重新构建
|
2026-06-11 16:45:34 +08:00 |
|
Rekey
|
805a23f72e
|
chore: 添加 Python __pycache__/ 和 .venv/ 到 .gitignore,清理已缓存文件
|
2026-06-08 18:21:16 +08:00 |
|
Rekey
|
1c9339a4db
|
feat(engine): 新增 Python 策略引擎模块
- config/settings.py:Pydantic 解析 env.yaml
- data/db.py:asyncpg 连接池管理
- data/reader.py:KlineReader 只读查询 TimescaleDB
- data/models.py:KlineRecord 等 Pydantic 模型,镜像 TypeORM 实体
- example/test_db.py:数据库查询验证示例
- README.md:引擎架构文档
|
2026-06-08 18:19:50 +08:00 |
|