Repository navigation
feat(ml): Stage 0 discipline scripts (98/98 tests) - #709
Merged
Merged
Conversation
…finstsb, transaction_costs (98/98 tests) Stage 0 ML/Trading curriculum (Track A from RooSync directive): - walk_forward.py: WalkForwardSplitter, PurgedKFold, CPCV (AFML Ch.7+12) - baselines.py: majority_class, naive_momentum, random_walk, buy_and_hold - eval_finstsb.py: FinTSB-style regime detection + per-regime evaluation - transaction_costs.py: Almgren-Chris cost model + gross vs net comparison All scripts: PEP 8, type hints, docstrings with academic references. References: Lopez de Prado AFML, FinTSB (TongjiFinLab), Hands-On AI Trading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jsboige
commented
May 4, 2026
jsboige
left a comment
Owner
Author
There was a problem hiding this comment.
COMMENT review (self-authored — cannot APPROVE)
Stage 0 discipline scripts (98/98 tests)
9 files, +1906: 4 new scripts + 4 test files + init.py.
Scripts reviewed
-
baselines.py (263 lines): majority_class, naive_momentum, random_walk, buy_and_hold +
_sharpe_from_returnshelper- Clean implementations, proper docstrings with NumPy-style parameters
naive_momentum_baseline: correctly shifts signals to avoid look-ahead (line ~105)random_walk_baseline: usesdefault_rng(good practice), reports p95 for deflated Sharpe testingbuy_and_hold_baseline: handles edge case wheretotal_return <= -1(returns -1.0 CAGR)
-
eval_finstsb.py (243 lines): regime detection + per-regime evaluation
- 4 regimes: uptrend, downtrend, volatility, black_swan — priority-ordered
validate_no_regime_failure: checks no regime has Sharpe below threshold- Proper handling of insufficient samples (< 5 → NaN instead of crash)
-
transaction_costs.py (reviewed from test coverage): commission + spread + market impact + slippage model
- Zero-volume edge case handled (
daily_volume=0.0) - Round-trip cost correctly modeled (half spread + commission per trade)
- Zero-volume edge case handled (
-
walk_forward.py (reviewed from test coverage): WalkForwardSplitter, PurgedKFold, CPCV
Tests (4 files, ~870 lines)
Thorough: balanced/imbalanced classes, trending/mean-reverting prices, SPY-like fixtures, edge cases (flat prices, zero returns, all-same-class). Test fixtures are realistic (SPY ~54% up-day frequency).
Anti-pattern compliance (cf. #703)
- Majority-class baseline always computed and reported
- Train-only normalization (anti-leakage)
- No hardcoded file paths in the scripts themselves
Minor notes
sys.path.appendin train scripts references../shared— fragile but consistent with project pattern- Self-contained (no external deps beyond numpy/pandas)
No bugs found. Ready for external APPROVE.
jsboige
added a commit
that referenced
this pull request
Jul 20, 2026
…7595) MGS-7-TSP.ipynb hardcoded `c:/dev/MetaGeneticSharp/...` absolute paths in cell 1 (6 #r directives + 1 prerequisite comment). Same anti-pattern as PR #7583 (MGS-7b N-D landscape) before its fix. Transform c:/dev/MetaGeneticSharp/ -> ..\MetaGeneticSharp\ (relative to notebook location at Search/Part4-Metaheuristics/, submodule at Search/MetaGeneticSharp/). Build config kept Debug (matches canonical). Verifications: - nbclient .net-csharp: 12/12 cells, 0 errors, all execution_count - promote ec+outputs: 12/12 cells promoted from .executed.ipynb - strip probeAddresses banner: 9 banner lines stripped from canonical (NOT from .executed.ipynb - C708-L5 NEW) - H.3 validate_pr_notebooks.py: PASS 1/1 (12 cells [.net-csharp]) - Real outputs preserved: 4 configs (baseline/islands/geometric-swap/ geometric-insertion/geometric-edge) + 3 exercises Submodule pointer NOT bumped (no submodule content change, only notebook paths). MGS-7b stays at PR #41 submodule-main SHA 30c3993c7219332c14d4a2477b44661c6fae8215. Co-authored-by: Claude-Code <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.
Summary
Scripts
walk_forward.pybaselines.pyeval_finstsb.pytransaction_costs.pyQuality Criteria (from directive)
Test plan
python -m pytest scripts/tests/ -v→ 98 passed in 2.79s🤖 Generated with Claude Code