# marketStream **Repository Path**: funlake/marketStream ## Basic Information - **Project Name**: marketStream - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-29 - **Last Updated**: 2025-11-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # marketStream 市场数据流处理系统 ## 环境变量设置 复制环境变量模板并配置: ```bash cp .env.example .env ``` 编辑 `.env` 文件,配置以下必需的环境变量: ```env # Binance API 配置(必填) BINANCE_API_KEY=your-binance-api-key-here BINANCE_API_SECRET=your-binance-secret-key-here # DeepSeek API 配置(必填) DEEPSEEK_API_KEY=sk-your-deepseek-api-key-here # 可选配置 BINANCE_TESTNET=false DEBUG=false ``` 获取 API 密钥: - Binance: https://www.binance.com/en/my/settings/api-management - DeepSeek: https://platform.deepseek.com/ ## 运行 ```bash # 安装依赖 pip install -e . # 启动服务 python3 -m src.marketStream.main ``` 服务默认运行在 http://localhost:5000 ## v9回测接口 ### 端点 `GET /api/strategy/backtesting/v9` ### 参数 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | symbol | string | 是 | 交易对符号(如 `BTCUSDT`) | | start_time | string | 是 | 开始时间(格式:`YYYY-MM-DD` 或 `YYYY-MM-DD HH:MM`)| | end_time | string | 是 | 结束时间(格式:`YYYY-MM-DD` 或 `YYYY-MM-DD HH:MM`)| | interval | string | 否 | 时间周期(默认:`15m`,可选:`5m`, `1h`, `4h`)| ### 示例 ```bash # 回测 BTCUSDT 一天的数据 curl "http://localhost:5000/api/strategy/backtesting/v9?symbol=BTCUSDT&start_time=2024-01-01&end_time=2024-01-02" # 回测 BTCUSDT 指定时间范围 curl "http://localhost:5000/api/strategy/backtesting/v9?symbol=BTCUSDT&start_time=2024-01-01%2009:00&end_time=2024-01-01%2012:00&interval=15m" ``` ### 响应示例 ```json { "code": 200, "data": { "version": "v0.0.9", "interval": "15m", "symbol": "BTCUSDT", "totalProfitUsdt": 150, "analysisCount": 48, "trades": [ { "action": "long", "period": "2024-01-01 09:00 - 2024-01-01 10:30", "profit": 75.50, "openPrice": 42000.00, "closePrice": 42075.50, "exitReason": "止盈-takeProfit", "profitRatio": 2.5 }, { "action": "short", "period": "2024-01-01 11:00 - 2024-01-01 11:45", "profit": 74.50, "openPrice": 42100.00, "closePrice": 42025.50, "exitReason": "止盈-measureMove", "profitRatio": 2.3 } ], "analyses": [ { "index": 9, "time": "2024-01-01 09:00:00", "action": "long", "reason": "上升趋势确认,突破压力位", "price": 42000.00, "stopLoss": 41850.00, "takeProfit": 42150.00, "measureMove": 42250.00, "breakoutPrice": 41980.00 } ] }, "msg": "success" } ``` ### 响应说明 - `version`: 回测版本号(v0.0.9) - `totalProfitUsdt`: 总盈亏(USDT) - `analysisCount`: AI分析次数 - `trades`: 交易记录列表 - `action`: 交易方向(long/short) - `period`: 交易周期 - `profit`: 盈亏金额 - `openPrice/closePrice`: 开仓/平仓价格 - `exitReason`: 平仓原因(止盈-takeProfit、止盈-measureMove、止损等) - `profitRatio`: 盈亏比 - `analyses`: AI分析详情 - `action`: 操作建议(long/short/hold/close) - `reason`: 分析原因 - `stopLoss/takeProfit/measureMove`: AI建议的止损/止盈/目标位价格 - `breakoutPrice`: 枢轴点算法计算的突破价格