Commit Graph

3 Commits

Author SHA1 Message Date
67b85ab232 Refactor: Implement WebSocket architecture with separated communication and business logic layers
- Implemented WebSocket protocol v1.0 specification with protocol headers, versioning, and batch support
- Renamed qtrade_server.py -> ws_server.py, client_adapter.py -> ws_client.py to reflect WebSocket implementation
- Created pure communication layer (WSClient) with only connect/send/close functionality
- Created business logic layer (BacktestClientAdapter) for protocol construction and signal parsing
- Updated bt_engine.py to use BacktestClientAdapter for strategy communication
- Fixed datetime formatting issues (time.strftime -> datetime.now().strftime for %f support)
- Fixed WebSocket 1000 OK close code logging issue
- Translated all logger output from Chinese to English for better compatibility
- Successfully tested with 242 K-lines data transmission

Architecture changes:
- networks/ layer: Pure WebSocket communication (no business logic)
- backtest/ layer: Business logic (protocol v1.0 message construction)
- Clear separation of concerns between transport and application layers
2025-12-25 16:15:56 +08:00
5734bf1fd0 feat: 实现XtQuant数据下载器和核心对象系统
- 新增核心对象模型(Tick, Kline, Order, Trade, Position, Account, Signal, Symbol)
- 使用Pydantic BaseModel实现自动验证
- 创建DatabaseManager管理数据库和表结构
- 实现BaseDataDownloader抽象基类
- 实现XtQuantDownloader下载历史K线数据
- 添加Config和Logger工具类
- 清理旧的微服务架构代码
- 更新配置文件为简化版本(去除Redis)
- 所有测试通过
2025-12-15 20:00:47 +08:00
099e193c2e feat: 完成回测引擎架构和服务管理优化
核心功能:
- 创建database_service (API方式管理数据库和表)
- 实现BacktestEngine (简洁的回测API,支持GUI/CLI)
- 回测引擎入口 (src/backtest/main.py)

服务管理优化:
- HTTPService支持后台运行 (CREATE_NO_WINDOW)
- 日志重定向到文件 (logs/<服务名>.log)
- 统一启动流程 (显示计划、进度、结果摘要)
- 优雅退出 (捕获KeyboardInterrupt)

代码结构重构:
- setup_services() - 配置服务
- start_xxx() - 启动流程
- main() - 简洁主函数
- 职责分离清晰,易于维护

新增文件:
- src/database_service/ - 数据库管理服务
- src/backtest/ - 回测引擎模块
- examples/backtest_gui_example.py - GUI示例
- docs/architecture/BACKTEST_ENGINE_DESIGN.md - 设计文档

配置文件:
- configs/global.yaml - 添加database_service端口
- src/backtest_service/app.py - 添加/health端点
2025-12-13 10:30:31 +08:00