# DeltaTrader **Repository Path**: fox_hu/delta-trader ## Basic Information - **Project Name**: DeltaTrader - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-25 - **Last Updated**: 2026-09-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DeltaTrader A股量化交易系统,支持多数据源行情获取、策略回测、风险管理、股票分析。 ## 项目结构 ``` DeltaTrader/ ├── config/ # 配置管理(YAML) ├── data/ # 数据层(多源: 聚宽/东方财富/新浪 + 限流 + 缓存) ├── strategy/ # 策略模块(双均线/周期选股/动量) ├── risk/ # 风险管理(止损止盈/仓位控制/日亏损限制) ├── engine/ # 回测引擎(模拟券商/执行器/预留实盘接口) ├── analysis/ # 股票分析(技术面/基本面/统计) ├── web/ # Web UI(Flask + ECharts) ├── example/ # 示例脚本 ├── price/ # 本地CSV行情数据 └── finance/ # 财务数据 ``` ## 快速开始 ### 安装依赖 ```bash pip install -r requirements.txt ``` ### 配置 复制示例配置并填写: ```bash cp config/config.example.yaml config/config.yaml # 编辑 config.yaml 填入聚宽账号等配置 ``` ### Web 分析界面 ```bash python -m web.app # 浏览器访问 http://localhost:5000 ``` 输入股票代码即可获取技术面(MA/MACD/RSI/布林带/KDJ)、基本面(PE/PB/市值)、统计特征(波动率/夏普/最大回撤)分析报告,支持导出 PDF。 ### 代码使用 ```python # 股票分析 from analysis.analyzer import StockAnalyzer result = StockAnalyzer('000001.XSHE', '2023-01-01', '2025-12-31').analyze() print(result['total_score'], result['rating']) # 回测 from engine.backtest import BacktestEngine from strategy.ma_strategy import ma_strategy from data.manager import get_daily_price data = get_daily_price('000001.XSHE', '2022-07-01', '2023-06-30') engine = BacktestEngine(strategy=ma_strategy) result = engine.run(data, code='000001.XSHE') print(result.summary()) ``` ## 功能模块 ### 行情数据 (data) - 多数据源: 聚宽/东方财富(akshare)/新浪(akshare) - 自动降级: 新浪 → 东方财富 → 聚宽 - 请求限流: 可配置最小间隔和每日上限 - 本地缓存: CSV 缓存 + 已有数据文件优先读取 ### 策略开发 (strategy) - 双均线策略 (MA) - 周期选股策略 (周四周一) - 动量策略 - 统计检验 (t检验) ### 风险管理 (risk) - 止损/止盈检查 - 单只股票最大仓位限制 - 最大持仓数量限制 - 单日最大亏损限制(触发后禁止开仓) ### 回测引擎 (engine) - 模拟券商: 手续费/印花税/滑点 - 逐日回测: 行情更新 → 风控检查 → 策略信号 → 执行 - 预留接口: Broker/TradeExecutor 抽象,可扩展实盘 ### 股票分析 (analysis + web) - 技术面: MA趋势/MACD/RSI/布林带/KDJ,综合评分 - 基本面: PE/PB/市值/行业,综合评分 - 统计: 年化收益/波动率/夏普/最大回撤/胜率 - Web界面: 输入股票代码 → ECharts图表 → PDF导出 ## 配置说明 编辑 `config/config.yaml`: ```yaml data: sources: joinquant: { enabled: true, phone: "...", password: "..." } eastmoney: { enabled: true } sina: { enabled: true } rate_limit: min_interval: 3 # 请求最小间隔(秒) daily_limit: 500 # 每日最大请求 risk: stop_loss_pct: 0.05 # 止损 5% take_profit_pct: 0.10 # 止盈 10% max_position_pct: 0.30 # 单股最大仓位 30% max_daily_loss_pct: 0.02 # 日最大亏损 2% max_total_positions: 10 # 最多持 10 只 trading: initial_capital: 1000000 commission_rate: 0.0003 slippage_pct: 0.001 stamp_tax_rate: 0.001 ```