Codebase analysis: findings report (no code changes)#2
Draft
Copilot wants to merge 1 commit intofeature/comprehensive-improvementsfrom
Draft
Codebase analysis: findings report (no code changes)#2Copilot wants to merge 1 commit intofeature/comprehensive-improvementsfrom
Copilot wants to merge 1 commit intofeature/comprehensive-improvementsfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Copilot
AI
changed the title
[WIP] Analyze and criticize existing codebase for improvements
Codebase analysis: findings report (no code changes)
Mar 1, 2026
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.
Deep audit of the ensemble branch (
feature/comprehensive-improvements) to identify remaining issues after three prior audit rounds. No code was changed — this PR documents findings only.Confirmed fixed (from prior audits)
All original P0 execution bugs resolved: per-position
_update_equity, stale-position closing inreconcile_target_weights, equity snapshot before reconciliation loop, sellweight_changesign, purged walk-forward CV replacing iloc split, LightGBM early stopping, risk engine initialization, bracket leg preservation, bridge created once outside loop, fill verification polling.Remaining issues found
High
_cancel_existing_sl_tp_orderscancellation logic is inverted (live_bot.py:357):Noneis included in theorder_classallowlist, so any sell-side order without an explicit class (regular limit sells, manual orders) gets cancelled. Only orders with a recognized bracket class (oco,oto,bracket) should be cancelled.Medium
mom_12_1,mr_zscore_60,sector_rel_momare inFEATURE_COLSbut absent from_WINSORIZE_COLSinfeatures.py. Outliers in these flow raw into training and inference.normalstate runs at 70% exposure (hmm_regime.py:70): Permanent 30% cash drag in baseline market conditions. Makes A/B comparison with Bot A (full exposure) structurally unfair and depresses returns mechanically.ensemble.py:365): When_fit_meta_learnerhas insufficient OOS data,validation_icstays 0.0 and the quality gate (< 0.02) triggers equal-weight fallback — even though the base models may have positive individual ICs._has_traded_todayfails closed silently on broker error (live_bot.py:522): Transient API errors at startup cause the bot to skip the cycle entirely with only a log line — noCRITICALalert fired.live_bot.py:119–125): Comment documents3x SL / 5x TP; live defaults are2x / 3x.predict.py:768): Single outlier score collapses all others toward zero, concentrating conviction weight and undermining HRP diversification. Rank-based normalization is more robust.Low
p=0.01→ ~10.5% false-positive rate per cycle.predict.py:83–88):_last_drift_report,_last_raw_ohlcv,_last_prediction_scoreswritten by main loop, read by polling thread — no synchronization.live_bot.py:1464): Redundant HTTP call; could slice the already-fetched 2y SPY data from initialization.predict.py:1027): Driftstart_runinsideget_ml_weightscould become a child of an unclosed training run on exception paths.base.pyreconcile_portfoliotarget_weight=0 skip (original Finding #6):execution.pywas fixed;BaseBroker.reconcile_portfoliowas not reviewed — status unconfirmed.sector_rel_momuniverse mismatch: Cross-sectional feature computed on a slightly different ticker universe at inference vs. training due to min-history filtering — structural (non-stochastic) drift.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.