核心功能: - Socket长连接通信架构,性能提升13倍 - 完整的股票数据处理模块,支持xtquant数据源 - MySQL数据库集成,使用Peewee ORM - 网格交易策略实现 - 多客户端并发支持 项目结构: - src/data_process_model/ - 数据处理核心模块 - src/network_model/ - Socket和HTTP通信实现 - src/strategy/ - 交易策略模块 - example_and_demos/ - 示例和演示代码 - test/ - 测试文件 主要特性: - 支持CSV和MySQL双重数据存储 - 自动数据下载和处理流水线 - 实时Socket通信,毫秒级响应 - 完善的错误处理和日志记录 - 模块化设计,易于扩展 性能指标: - 平均延迟: 0.31ms (HTTP: 4.13ms) - 理论QPS: 3242 (HTTP: 242) - 支持50个并发客户端连接
46 lines
1.4 KiB
Markdown
46 lines
1.4 KiB
Markdown
# Example and Demos Directory Structure
|
|
|
|
This directory contains example code and demonstration scripts organized by protocol type.
|
|
|
|
## Directory Structure
|
|
|
|
```
|
|
example_and_demos/
|
|
├── http/ # HTTP相关的示例和演示
|
|
│ ├── http_client_example.py # HTTP客户端示例
|
|
│ └── run_http_server.py # HTTP服务器启动脚本
|
|
└── socket/ # Socket相关的示例和演示
|
|
├── run_socket_server.py # 简化版Socket服务器启动脚本
|
|
└── socket_client_example.py # 简化版Socket客户端示例
|
|
```
|
|
|
|
## Usage
|
|
|
|
### HTTP Examples
|
|
- **HTTP Client Example**: `python example_and_demos/http/http_client_example.py`
|
|
- **HTTP Server**: `python example_and_demos/http/run_http_server.py`
|
|
|
|
### Socket Examples
|
|
- **Simple Socket Server**: `python example_and_demos/socket/run_socket_server.py`
|
|
- **Simple Socket Client**: `python example_and_demos/socket/socket_client_example.py`
|
|
|
|
## Quick Start
|
|
|
|
Use the main quick start script at project root:
|
|
```bash
|
|
python quick_start.py
|
|
```
|
|
|
|
Or use the Socket-specific quick start:
|
|
```bash
|
|
python quick_start_socket.py
|
|
```
|
|
|
|
## Performance Comparison
|
|
|
|
Socket implementation shows **13x performance improvement** over HTTP:
|
|
- HTTP: 4.13ms average latency, 242 QPS
|
|
- Socket: 0.31ms average latency, 3,242 QPS
|
|
|
|
For performance testing, see `/test/` directory (test_stress.py).
|