Commit Graph

2 Commits

Author SHA1 Message Date
b311fbdece 性能优化与测试:添加DuckDB存储性能基准测试和逐条插入场景测试
主要更改:
- 添加benchmark_storage.py:全面的K线数据存储性能测试
  * 批量插入测试 (100万条数据)
  * 逐条插入测试 (36,000条实时场景)
  * 对比DuckDB文件/内存、Pickle、Parquet、DataFrame
  * 添加复合索引 (symbol + timestamp) 优化

- 性能测试结果:
  * 批量插入:DuckDB内存 790万行/秒,Pickle最快
  * 逐条插入:DuckDB内存 1,165行/秒 (最快)
  * DataFrame+Parquet 最慢 (46行/秒,慢25倍)
  * 时间段查询:DuckDB索引 8ms vs DataFrame 32ms

- 修复grid_strategy.py的Pylance类型错误:
  * 添加None类型检查
  * 移除不必要的f-string
  * 清理未使用变量

- 简化strategy_manager.py架构:
  * 移除冗余的position_manager/risk_manager/strategy_executor
  * 统一状态管理:get_status() / restore_state()
  * 优化启用/禁用策略逻辑

- 清理废弃文档和配置模块
- 添加性能测试分析报告和技术研究文档
2026-01-17 23:52:59 +08:00
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