Files
myquant/CLAUDE.md
T
simonandSimon 22ce3a6aea security: 安全规范 + 敏感数据脱敏
- CLAUDE.md 新增安全规范章节(禁止提交 / 必须提供 .env.example)
- finance/config/settings.py 硬编码密码移除
- djapi/api/video/audioRead.py API Key 替换为占位符
- 新增 finance/.env.example 示例配置
- .gitignore 解除 .env.example 排除

Co-Authored-By: Simon <simon@doorcome.cn>
2026-06-17 21:20:07 +08:00

106 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CLAUDE.md
cc-cursor — Mac Mini 单机量化研究平台。全链路:Data → Factor → Backtest → Optimize → ML → Sentiment → Agent。
## 速查索引
| 模块 | 详情文件 | 核心入口 |
|------|---------|---------|
| 数据层 + 数据库 | `CLAUDE-data.md` | `from data.data_manager import DataManager` |
| 因子引擎 + 情绪 | `CLAUDE-factors.md` | `from factors.registry import get_factor` |
| 回测 + 优化 | `CLAUDE-backtest.md` | `from backtest.vectorbt.engine import VectorBTEngine` |
| ML 模型 | `CLAUDE-ml.md` | `from models.lightgbm.model import LightGBMModel` |
| Agent 系统 + CLI | `CLAUDE-agents.md` | `python cli/agent_cli.py daily` |
## 环境
```bash
conda activate quant # Python 3.11.13
bash shared/script/autossh.sh # DB SSH 隧道
```
## 任务→文档路由
| 任务类型 | 先读取 |
|---------|--------|
| 数据源/数据库/cache 相关 | `CLAUDE-data.md` |
| 因子/情绪/新闻相关 | `CLAUDE-factors.md` + `CLAUDE-reference.md` |
| 回测/优化/策略相关 | `CLAUDE-backtest.md` |
| ML 模型/特征工程相关 | `CLAUDE-ml.md` |
| Agent/CLI/报告相关 | `CLAUDE-agents.md` |
| API 参数/第三方库 | 调用 `mcp__mcphub__context7-query-docs` |
| 因子名/类名/表结构速查 | `CLAUDE-reference.md` |
## 多步任务规则
复杂任务(涉及 3+ 文件或 2+ 模块)执行前:
1. 输出执行计划清单(步骤 + 每步验证方法)
2. 每步完成后验证通过才继续
3. 遇到失败先定位根因,不跳过
## 核心设计约束(必须遵守)
- 数据流:`Data → Factor → Model → Strategy → Backtest → Report`
- 策略层禁止直接访问 AkShare/Tushare → 全部通过 `DataManager`
- 模型层禁止直接访问数据库 → 全部通过 DataManager
- 指数代码规则:`.SH`=指数, `.SZ` 开头非 399=个股
- 数据源优先级:Tushare → AkShare (fallback)
- 当日数据未缓存 → 先 `dm.sync_daily`;增量同步只更新已缓存股票
- 修改多文件前先说明:文件清单、原因、影响;优先小范围修改
## CLI 常用命令
```bash
python cli/agent_cli.py daily # 5步完整流程
python cli/agent_cli.py picks 15 # 选股
python cli/agent_cli.py risk # 风险评估
python cli/agent_cli.py report 20260603 # 生成日报
python cli/agent_cli.py warmup 50 # 首次预热缓存
python cli/demo_data_manager.py --ts_code 600519.SH
python cli/demo_factor_engine.py --ts_code 300750.SZ
python cli/demo_backtest.py --ts_code 000001.SZ
python cli/demo_optimizer.py --ts_code 000001.SZ --trials 100
python cli/demo_ml.py --ts_code 000001.SZ --lookahead 5
python cli/demo_sentiment_detail.py --ts_code 600519.SH --date 20260603
```
## 技术栈
| 组件 | 技术 | 环境 |
|------|------|------|
| 数据获取 | AkShare + Tushare (双源) | conda quant |
| 数据库 | MariaDB (SSH 隧道) | mac_ 前缀表 |
| 因子/特征 | pandas / numpy / sklearn | conda quant |
| 回测 | VectorBT 1.0 | conda quant |
| 优化 | Optuna 4.9 | conda quant |
| ML | LightGBM 4.6 + CatBoost 1.2 | conda quant |
| NLP | Qwen (DashScope / Ollama) | .env 配置 |
| Agent | 自研编排器 | finance/agents/ |
| API | Django 5.2 + uWSGI | djapi/ |
## 安全规范
### 禁止提交
- `.env`(含真实 key
- API Key`sk-*``TUSHARE_TOKEN` 等)
- Cookie / Session
- Token / 密钥
- 个人隐私数据(手机号、身份证、密码)
### 必须提供
- `.env.example` — 仅含占位符的示例配置,如:
```
TUSHARE_TOKEN=your_token_here
QWEN_API_KEY=sk-your-key-here
MAC_DB_PASSWORD=your_password_here
```
### 提交前检查
```bash
grep -r "sk-\|token\|_H(lU\|password" --include="*.py" --include="*.md" --include="*.yaml" | grep -v ".example\|your_token\|your_password"
```