Composite S/R loss, SEC filings pipeline, CVaR benchmark, and pyfolio visualization#74
Open
v-atharva wants to merge 3 commits intoatharva/feature_selectionfrom
Open
Composite S/R loss, SEC filings pipeline, CVaR benchmark, and pyfolio visualization#74v-atharva wants to merge 3 commits intoatharva/feature_selectionfrom
v-atharva wants to merge 3 commits intoatharva/feature_selectionfrom
Conversation
… benchmark, pyfolio - Add CompositeSRLoss: Sharpe + price-action S/R + psychological levels + macro regime + optional SEC fundamental alignment - Extend Trainer to pass input features and fundamentals to the loss; include composite loss parameters in optimizer when applicable - SEC pipeline (edgartools): fetch 10-K/10-Q/8-K, XBRL-derived features, composite scores; run_sec_collection CLI and Parquet cache - CVaR benchmark (CVXPY): rolling Mean-CVaR weights vs LSTM allocations - pyfolio-reloaded: weights/returns to tearsheets and strategy comparison - Config: CompositeSRLoss and CVaRBenchmark hparams; sec_filings_dir paths - Dependencies: cvxpy, edgartools, pyfolio-reloaded, empyrical-reloaded - Unit tests for composite loss, CVaR, SEC helpers, pyfolio conversion Made-with: Cursor
…ate, data-driven robustness - Add TimeframeImportanceFn MLP: learnable lookback→importance weights (longer-period S/R levels carry more weight by default) - Add _detect_pivots(): rolling-window pivot scores across [5,10,21,42,63,105d] - Add MacroOverrideGate: adaptive omega in (0,1) that re-scales penalty weights based on macro rate-of-change (extreme macro → macro penalty dominates) - Sector-aware S/R scaling via sector_assignment_50.csv - Per-ticker macro sensitivity weighting via ticker_macro_rankings.csv - Cross-ticker correlation guard (pre-computed from ret_train) - Extract shared _compute_delta_macro() helper - All features off by default (backward-compatible) - 28 tests added covering multi-TF, gate, sector, sensitivity, correlation Co-Authored-By: Claude Sonnet 4.6 <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
This PR extends
financial_loss_functionswith a multi-component training objective, optional SEC-derived fundamentals, a CVaR portfolio benchmark, and pyfolio-based strategy reporting. It is based onatharva/feature_selection.Changes
Composite loss (
CompositeSRLoss)composite_fundamental_scores.csvis present.Training
Trainerpasses(weights, y, x, fundamentals?)to the loss; legacy 2-arg losses still work.pipeline.pytrains BaseLSTM (Sharpe baseline), BaseLSTM + composite, AttentionLSTM + composite, runs CVaR benchmark, equal weight, and generates pyfolio tearsheets plus a CSV summary.Data & tooling
src/data_collection/sec_filings.pyandscripts/run_sec_collection.py(edgartools; cache underdata/raw/sec_filings/).src/models/cvar_benchmark.py(CVXPY / CLARABEL, no GPU requirement).src/evaluation/pyfolio_viz.py(pyfolio-reloaded).Config & dependencies
config/hparams.json:CompositeSRLoss,CVaRBenchmark.config/paths.json:sec_filings_dir,pyfolio_output.requirements.txt:cvxpy,edgartools,pyfolio-reloaded,empyrical-reloaded.Tests
tests/unit/test_composite_loss.py,test_cvar_benchmark.py,test_sec_filings.py,test_pyfolio_viz.py.Other
exploration/feature_selection_findings.ipynbas part of the working tree.How to verify
cd financial_loss_functions pip install -r requirements.txt pytest tests/unit/test_composite_loss.py tests/unit/test_cvar_benchmark.py tests/unit/test_sec_filings.py tests/unit/test_pyfolio_viz.py -vNotes
EDGAR_IDENTITY/set_identityfor edgartools; training runs without SEC data (fundamental term skipped).cvxpyis required for the CVaR benchmark tests.Made with Cursor