# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview AI 协助分析交易数据和回测的仓库。主要用来做策略回测、行情分析、期权定价、资产配置等量化相关操作。 ## Python Environment - Python 3.13 (Homebrew at `/opt/homebrew/bin/python3`) - `pip` 与 `python3` 版本可能不对应(pip 可能指向 3.9),安装包时用 `/opt/homebrew/bin/python3 -m pip install ` 或创建 venv - `.venv/` 已 gitignore - 常用库: `pandas`, `numpy`, `akshare`, `yfinance`, `tushare` ## Data Sources 按优先级排序: 1. **Tushare Pro** — 优先使用,数据最全(股票、期货、指数、期权等) - Token: `76efd8465f9f2591aa42a385268e06acf6b80b7a15be2267ad2281b7` - 用法: `import tushare as ts; ts.set_token('...'); pro = ts.pro_api()` 2. **akshare** — 备选,无需 token,覆盖面广 - A股指数: `ak.stock_zh_index_daily(symbol="sh000300")` - 全球指数: `ak.index_global_hist_em(symbol="纳斯达克")` - 个股: `ak.stock_zh_a_hist(symbol="600030", adjust="qfq")` - 期货主连: `ak.futures_main_sina(symbol="FG0")` 3. **yfinance** — 海外市场(注意频次限制,需加 sleep) ## Conventions - 期货主连代码格式: `FG0` (品种代码 + "0") - A股个股复权方式: 前复权 (`adjust="qfq"`) - 图表输出到 `/tmp/` 临时目录,不回写仓库