@@ -464,12 +464,48 @@ class FundingRateStrategy(bt.Strategy):
464464
465465### Documentation & Resources
466466
467- - 📚 [ Official Backtrader Documentation] ( https://www.backtrader.com/ )
467+ - 📚 [ Project Documentation Index] ( docs/README.md )
468+ - 🛠️ [ Installation & Troubleshooting Guide] ( docs/INSTALLATION_GUIDE.md )
469+ - 🧾 [ Changelog] ( docs/CHANGELOG.md )
470+ - 🐛 [ DataTrades Fix Note] ( docs/DATATRADES_FIX.md )
471+ - 🔌 [ ExtendPandasFeed Fix Note] ( docs/EXTENDED_FEED_FIX.md )
472+ - 📖 [ Official Backtrader Documentation] ( https://www.backtrader.com/ )
468473- 📝 [ CSDN Tutorial Series (Chinese)] ( https://blog.csdn.net/qq_26948675/category_10220116.html )
469474- 💬 [ Issue Tracker - Gitee] ( https://gitee.com/yunjinqi/backtrader/issues )
470475- 💬 [ Issue Tracker - GitHub] ( https://github.com/cloudQuant/backtrader/issues )
471476- 🔧 [ Development Guide] ( CLAUDE.md )
472477
478+ ### Project Structure
479+
480+ ```
481+ backtrader/
482+ ├── backtrader/ # Core framework package
483+ ├── docs/ # Project docs, changelog, installation guide, fix notes
484+ ├── examples/ # Runnable example projects
485+ ├── scripts/ # Maintenance & QA helper scripts
486+ │ ├── run_master_tests.py # Full pytest run + HTML report
487+ │ ├── run_test_with_log.py # Run a single test with branch-aware logging
488+ │ ├── sync_and_test.py # Sync a test file across branches & run it
489+ │ ├── profile_performance.py # cProfile-based strategy profiler
490+ │ ├── debug_macd_replay.py # MACD-in-replay debugging harness
491+ │ ├── backtest_strategy_regression_expected.py # Regression baseline generator
492+ │ ├── run_all_backtests.py # Batch backtest runner
493+ │ └── test_python_versions_simple.sh/.bat # Multi-version conda test runner
494+ ├── strategies/ # Shared strategy helpers (e.g. benchmark_metrics)
495+ ├── studies/ # Research notebooks & UML
496+ ├── tests/ # Pytest test suites
497+ │ ├── original_tests/ # Upstream backtrader tests
498+ │ ├── strategies/ # In-house strategy tests
499+ │ ├── funding_rate_examples/ # Crypto funding-rate tests
500+ │ └── functional/strategies_regression/ # 1000+ generated regression scripts (gitignored)
501+ ├── pyproject.toml / setup.py / requirements.txt
502+ └── README.md / CLAUDE.md / LICENSE
503+ ```
504+
505+ > ` tests/functional/strategies_regression/ ` is generated locally by
506+ > ` scripts/backtest_strategy_regression_expected.py ` and is intentionally
507+ > excluded from version control.
508+
473509### Testing
474510
475511``` bash
@@ -480,11 +516,21 @@ pytest tests
480516pytest tests --cov=backtrader --cov-report=html
481517
482518# Run specific test category
483- pytest tests/original_tests # Core functionality
484- pytest tests/funding_rate_examples # Crypto features
519+ pytest tests/original_tests # Core functionality
520+ pytest tests/funding_rate_examples # Crypto features
521+ pytest tests/strategies # In-house strategies
485522
486523# Run in parallel
487524pytest tests -n 4
525+
526+ # Convenience wrappers (always run from repo root)
527+ python scripts/run_master_tests.py # Full suite + HTML report
528+ python scripts/run_test_with_log.py tests/strategies/test_18_etf_rotation_strategy.py
529+ bash scripts/test_python_versions_simple.sh # Multi Python version sweep
530+
531+ # Regenerate strategy regression baselines (long-running)
532+ python scripts/backtest_strategy_regression_expected.py \
533+ tests/functional/strategies_regression --workers 4 --overwrite
488534```
489535
490536### Contributing
@@ -499,6 +545,13 @@ We welcome code contributions, bug reports, and feature suggestions:
499545
500546### Changelog
501547
548+ #### 2026 Updates
549+ - ✅ Reorganised root-level helper scripts under ` scripts/ `
550+ - ✅ Added the strategies regression framework (1000+ per-strategy ` run.py ` baselines, generated locally and gitignored)
551+ - ✅ Made ` backtrader.analyzers.pyfolio ` lazy-load ` empyrical ` so ` import backtrader ` works without it on pandas 3
552+ - ✅ Replaced ` risk_free_rate ` keyword with ` riskfreerate ` for ` SharpeRatio ` across the regression suite
553+ - ✅ Normalised ` comminfo.get_param('mult') ` usage to ` getattr(comminfo.p, 'mult', 1.0) `
554+
502555#### 2024 Updates
503556- ✅ Added funding rate backtesting support for cryptocurrency perpetual contracts
504557- ✅ Fixed Python 3.12 and 3.13 compatibility issues
@@ -511,7 +564,7 @@ We welcome code contributions, bug reports, and feature suggestions:
511564- ✅ Fixed multiple known bugs
512565- ✅ Enhanced CTP integration
513566
514- For detailed changelog, see [ CHANGELOG.md] ( CHANGELOG.md ) (if available )
567+ For detailed changelog, see [ docs/ CHANGELOG.md] ( docs/ CHANGELOG.md)
515568
516569### License
517570
@@ -976,12 +1029,47 @@ class FundingRateStrategy(bt.Strategy):
9761029
9771030### 文档与资源
9781031
979- - 📚 [ 官方 Backtrader 文档] ( https://www.backtrader.com/ )
1032+ - 📚 [ 项目文档索引] ( docs/README.md )
1033+ - 🛠️ [ 安装与环境排查] ( docs/INSTALLATION_GUIDE.md )
1034+ - 🧾 [ 更新日志] ( docs/CHANGELOG.md )
1035+ - 🐛 [ DataTrades 修复说明] ( docs/DATATRADES_FIX.md )
1036+ - 🔌 [ ExtendPandasFeed 修复说明] ( docs/EXTENDED_FEED_FIX.md )
1037+ - 📖 [ 官方 Backtrader 文档] ( https://www.backtrader.com/ )
9801038- 📝 [ CSDN 教程系列] ( https://blog.csdn.net/qq_26948675/category_10220116.html )
9811039- 💬 [ 问题反馈 - Gitee] ( https://gitee.com/yunjinqi/backtrader/issues )
9821040- 💬 [ 问题反馈 - GitHub] ( https://github.com/cloudQuant/backtrader/issues )
9831041- 🔧 [ 开发指南] ( CLAUDE.md )
9841042
1043+ ### 项目结构
1044+
1045+ ```
1046+ backtrader/
1047+ ├── backtrader/ # 核心框架包
1048+ ├── docs/ # 项目文档、更新日志、安装指南和修复说明
1049+ ├── examples/ # 可运行示例项目
1050+ ├── scripts/ # 辅助维护与 QA 脚本
1051+ │ ├── run_master_tests.py # 完整 pytest 运行 + HTML 报告
1052+ │ ├── run_test_with_log.py # 单个测试运行并按分支输出日志
1053+ │ ├── sync_and_test.py # 在分支间同步测试文件并对比运行
1054+ │ ├── profile_performance.py # 基于 cProfile 的策略性能分析
1055+ │ ├── debug_macd_replay.py # MACD replay 模式调试环境
1056+ │ ├── backtest_strategy_regression_expected.py # 回归基准生成器
1057+ │ ├── run_all_backtests.py # 批量回测运行器
1058+ │ └── test_python_versions_simple.sh/.bat # 多 Python 版本 conda 测试
1059+ ├── strategies/ # 公用策略辅助包(如 benchmark_metrics)
1060+ ├── studies/ # 研究笔记与 UML 图
1061+ ├── tests/ # Pytest 测试集
1062+ │ ├── original_tests/ # 上游原版测试
1063+ │ ├── strategies/ # 自用策略测试
1064+ │ ├── funding_rate_examples/ # 加密货币资金费率测试
1065+ │ └── functional/strategies_regression/ # 1000+ 个生成的回归脚本(已加入 .gitignore)
1066+ ├── pyproject.toml / setup.py / requirements.txt
1067+ └── README.md / CLAUDE.md / LICENSE
1068+ ```
1069+
1070+ > ` tests/functional/strategies_regression/ ` 由
1071+ > ` scripts/backtest_strategy_regression_expected.py ` 本地生成,不跟随仓库提交。
1072+
9851073### 测试
9861074
9871075``` bash
@@ -992,11 +1080,21 @@ pytest tests
9921080pytest tests --cov=backtrader --cov-report=html
9931081
9941082# 运行特定测试类别
995- pytest tests/original_tests # 核心功能
996- pytest tests/funding_rate_examples # 加密货币特性
1083+ pytest tests/original_tests # 核心功能
1084+ pytest tests/funding_rate_examples # 加密货币特性
1085+ pytest tests/strategies # 自用策略
9971086
9981087# 并行运行
9991088pytest tests -n 4
1089+
1090+ # 便捷包装脚本(始终从仓库根目录运行)
1091+ python scripts/run_master_tests.py # 完整测试套件 + HTML 报告
1092+ python scripts/run_test_with_log.py tests/strategies/test_18_etf_rotation_strategy.py
1093+ bash scripts/test_python_versions_simple.sh # 多 Python 版本扫描
1094+
1095+ # 重新生成策略回归基准(耗时较长)
1096+ python scripts/backtest_strategy_regression_expected.py \
1097+ tests/functional/strategies_regression --workers 4 --overwrite
10001098```
10011099
10021100### 贡献指南
@@ -1011,6 +1109,13 @@ pytest tests -n 4
10111109
10121110### 更新日志
10131111
1112+ #### 2026年更新
1113+ - ✅ 根目录辅助脚本全部归档到 ` scripts/ `
1114+ - ✅ 新增策略回归测试框架(1000+ 个以策略为粒度的 ` run.py ` 基准,本地生成、已 gitignore)
1115+ - ✅ ` backtrader.analyzers.pyfolio ` 改为懒加载 ` empyrical ` ,在 pandas 3 下也能正常 ` import backtrader `
1116+ - ✅ 策略回归套件中将 ` SharpeRatio ` 的 ` risk_free_rate ` 参数统一改为 ` riskfreerate `
1117+ - ✅ 将 ` comminfo.get_param('mult') ` 调用统一为 ` getattr(comminfo.p, 'mult', 1.0) `
1118+
10141119#### 2024年更新
10151120- ✅ 增加了加密货币永续合约资金费率回测支持
10161121- ✅ 修复了 Python 3.12 和 3.13 兼容性问题
@@ -1023,7 +1128,7 @@ pytest tests -n 4
10231128- ✅ 修复了多个已知 bug
10241129- ✅ 增强了 CTP 集成
10251130
1026- 详细更新日志请查看 [ CHANGELOG.md] ( CHANGELOG.md ) (如果有)
1131+ 详细更新日志请查看 [ docs/ CHANGELOG.md] ( docs/ CHANGELOG.md)
10271132
10281133### 许可证
10291134
0 commit comments