Worktree report enhancement#45
Merged
Merged
Conversation
Comprehensive design for rebuilding 31 examples into a 20-file three-tier progressive structure (Foundation → Intermediate → Practical) with shared infrastructure, code standards, scientific rigor requirements, and tutorial synchronization plan. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- examples/_defaults.py: Centralized trading costs (2024 rates), stock codes, relative dates, data verification, evaluation panel - tests/test_examples_smoke.py: Smoke test suite checking syntax, imports, code standards (no star imports, no private APIs, docstrings, __main__ guards, _defaults usage) - mkdocs.yml: Add pymdownx.snippets for tutorial code references Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 01_fetch_data: Data APIs with explicit imports and _defaults - 02_write_strategy: MA crossover with strategy pattern walkthrough - 03_run_backtest: Lower-level API with manual trade log inspection - 04_stock_screener: scan_market + golden cross + restriction + query() - 05_reports: All 4 report formats + complete metric key reference - 06_local_data: Local cache workflow with argparse CLI - 07_lifecycle: before_trading_start/after_trading_end + ST detection All use explicit imports, _defaults, relative dates, __main__ guards. 49/49 smoke tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
New intermediate layer (08-14): utils library, attribution, index/concept, portfolio backtest, paper trade, A-share sentiment, portfolio risk. New practical layer (15-20): Bollinger, MACD+volume, multi-factor, grid trading, S/R portfolio, All-Weather Alpha. Removed 21 deprecated files (old numbered duplicates, prototypes, PTrade export). All examples now use explicit imports, consistent trading costs (2024 rates), and relative dates from _defaults. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Intermediate (08-14): utils library, attribution, index/concept, portfolio backtest, paper trade, A-share sentiment, portfolio risk. Practical (15-20): Bollinger, MACD+volume, multi-factor, grid trading, S/R portfolio, All-Weather Alpha combined strategy. All use explicit imports, _defaults for costs/dates, correct trading costs (stamp duty 0.05%, commission 0.025%). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Stamp duty: close_tax 0.001 → 0.0005 (0.05%, halved since Aug 2023) - Commission: 0.0003 → 0.00025 (0.025%, includes regulatory fees) - Percentage comments updated to match new rates - Example file references updated for new numbering scheme - Fee table in ashare-market.md corrected 13 tutorial files + 4 reference files updated. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
examples/README.md and docs/examples/index.md rewritten with: - 3-tier organization: Foundation (01-07), Intermediate (08-14), Practical (15-20) - Updated file references matching new numbering - Trading cost standards table (2024 rates) - Shared infrastructure section (_defaults.py, smoke tests) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Three-layer quality assurance for documentation: 1. CLAUDE.md Workflow Rules (7 rules): - Doc translation sync: always update .en.md with .md - Example modification gate: smoke tests + index updates - API change cascade: docs + examples + reference - New example checklist: docstring, imports, _defaults - Trading cost consistency: _defaults.py as source of truth - Validation before commit: doc_sync + smoke + mkdocs - Commit message conventions 2. scripts/check_doc_sync.py: validation script - Translation coverage check - Stale example reference detection (with --fix auto-repair) - Trading cost consistency check - Example file existence verification 3. .github/workflows/doc-sync.yml: CI pipeline - Runs on docs/ or examples/ changes - Checks doc sync, smoke tests, mkdocs build Also fixes 12 tutorial files with stale example references caught by the new check_doc_sync.py script. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Force-add CLAUDE.md (was in .gitignore) because it contains 7 essential workflow rules for documentation sync, example quality gates, API change cascade, and commit conventions. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fixed by scripts/check_doc_sync.py --fix: - tutorials/00-getting-started.md: 19_local_data → 06_local_data - tutorials/02-backtesting.md: 19_local_data, 20_sr_strategy refs - tutorials/03-optimization.md: 20_sr_strategy → 19_sr_portfolio - tutorials/04-live-trading.md: 13_ptrade, 20_sr_strategy refs - tutorials/05-rsi-mean-reversion.md: 14_bollinger, 18_comparison - tutorials/06-sector-rotation.md: 16_multi_factor → 17_multi_factor - tutorials/07-multi-factor.md: 09_attribution, 16_multi_factor - tutorials/08-combined-strategy.md: 14 stale refs - tutorials/10-ashare-data-risk.md: 08_lifecycle, 25_sentiment - tutorials/index.md: 13 stale refs in strategy lookup table - how-to/read-reports.md: 19_local_data → 06_local_data - how-to/export-ptrade.md: 13_ptrade → 12_paper_trade Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Complete English (.en.md) translation coverage:
- 15 tutorials (00-10, index, 4 prerequisites)
- 14 how-to guides (all)
- 10 reference pages (all)
- 5 explanation pages (all)
- 4 project pages (FAQ, changelog, contributing, security)
- 1 examples index
Translation conventions:
- A-share terms: North-bound capital, limit up/down, margin trading,
ST stocks, T+1 settlement, stamp duty, restricted share unlock
- Quant terms: Sharpe ratio, max drawdown, Bollinger Bands,
golden cross/death cross, support/resistance
- Trading costs: stamp duty 0.05%, commission 0.025%
- Internal doc links keep original paths (mkdocs-i18n resolves)
- Explicit heading anchors ({ #id }) where TOC self-references
require stable IDs across slugify implementations
Also fixes stale example refs in tutorials/05 and tutorials/index.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comprehensive redesign of HTML/PNG/Markdown/JSON backtest reports: - Dark theme (Bloomberg-inspired), 5-layer information pyramid - Strategy grading system with 6-dimension radar - Agent-First JSON structure for AI optimization loops - New charts: monthly heatmap, rolling metrics, return distribution Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
12-task plan covering dark theme colors, analyze_returns() extensions, grading functions, Agent-First JSON, 4-panel PNG, dark HTML template, and full regression gate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add DARK_COLORS palette and apply_matplotlib_dark_theme() to brand.py - Extend analyze_returns() with monthly_returns, rolling_sharpe_60d, rolling_volatility_60d, daily_returns_stats, per_stock_pnl, drawdown_periods - Add grade_strategy(), diagnose_bottleneck(), recommend_params() for 6-dimension strategy scoring Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Export grade_strategy, diagnose_bottleneck, recommend_params - Add 18 tests for grading, diagnosis, and recommendation functions Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- generate_chart(): dark 4-panel layout (cumulative + dimension bars + drawdown + monthly strip) - generate_report_md(): grade breakdown, monthly returns, rolling metrics, top 5 drawdown periods - generate_report_json(): Agent-First structure with verdict, targets, diagnostics, recommendations, grade, time_series - generate_html_report(): dark Bloomberg theme with hero, radar, tabbed charts, monthly heatmap, return distribution histogram - Add _calc_strategy_score() helper and grade_data to _calc_metrics() Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
AlanFokCo
added a commit
that referenced
this pull request
Jun 5, 2026
- JSON report: add backward-compatible risk_metrics/cumulative_returns keys so Web Studio and examples/05 continue to work - JSON report: filter inf/nan to null for valid JSON serialization - Sortino ratio: fix formula from std(negative returns) to correct LPM2 downside deviation around risk-free rate - Monthly returns strip: fix x-position indexing (was using iteration index instead of calendar month) and show last 12 months for multi-year backtests - Brand text: add text_color param to apply_matplotlib_brand so brand text is visible on dark backgrounds - PNG chart: restore buy/sell trade markers with dark theme colors - HTML report: eliminate redundant analyze_returns() call by caching raw analytics in _calc_metrics - API cascade: update docs (reports-format, api-analysis in zh+en) and example 09 with grade_strategy/diagnose_bottleneck/recommend_params Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.