Repository navigation
Release 1.3.0: verified analytics and portfolio fixes - #11
Merged
Merged
Conversation
…sweep 11-25) An unscored (NaN) first setting stayed "best" for the whole search because NaN compares False against every score, so the pick depended on grid order. Settings whose score is None, NaN or inf stay in results and are never selected; no finite score, or an empty grid, raises ValueError instead of returning a blank best or a score of 0.0.
… definition fixes - The scalar form returns the value at the latest bar. A missing bar no longer yields a value from before the gap: SMA blanks only the windows holding it (as pandas), recursive smoothers turn NaN (as TA-Lib) and a NaN latest value warns. Empty input raises instead of returning 0. - SMA, EMA, DEMA, TEMA, MACD, Bollinger, KAMA and Wilder smoothing skip a leading NaN warm-up, so indicators of indicators match TA-Lib; RSI of an SMA no longer counts the warm-up as flat bars; stochastic %D no longer fills the %K warm-up with 50. - RSI of an unmoving price is NaN (0/0) instead of 0, in NumPy and Rust. - momentum() stays callable after other momentum indicators import the submodule of the same name. - pandas DataFrames and Series work everywhere; 2-D arrays, derived sources on a bare series and obv() without volume raise. Rust kernels only run on complete data, Rust Garman-Klass only with its fixed 252-day setting. - Ichimoku refuses displacement < 1, Supertrend flips on the crossing bar (pandas-ta), EMA and MACD document their seed, Hurst uses the bias-corrected Anis-Lloyd-Peters rescaled range. Fixes CPZ-Lab/cpzai#3040 Fixes CPZ-Lab/cpzai#3052 Fixes CPZ-Lab/cpzai#3053 Fixes CPZ-Lab/cpzai#3054 Fixes CPZ-Lab/cpzai#3071 Refs CPZ-Lab/cpzai#3072 (partial: the global trading-days setting is documented, not added) Fixes CPZ-Lab/cpzai#3073
…shorts, attribution - fundamental_factors builds exposures from data known before each day (momentum t-252..t-21, size from the previous close's cap); noise no longer shows a momentum premium. Missing caps or book values raise. - turnover_analysis reports the rebalance cost in bps of the book and in dollars instead of summing per-trade bps. - CostModel: estimate documented as one leg, breakdown() applies permanent_fraction, unknown models raise, Almgren-Chriss refuses settings it ignores, sells cost the same as buys in every impact model. - alpha_decay_capacity counts short legs and refuses positions without ADV. - brinson_fachler raises on unmapped holdings and counts net-short sectors. - Information ratio is active return over tracking error; per-factor risk uses the Euler split; drawdowns count a loss on the first return. - cross_validate and grid_search accept Polars and pandas frames. Fixes CPZ-Lab/cpzai#3006 Fixes CPZ-Lab/cpzai#3029 Fixes CPZ-Lab/cpzai#3039 Fixes CPZ-Lab/cpzai#3045 Fixes CPZ-Lab/cpzai#3050 Fixes CPZ-Lab/cpzai#3070 Fixes CPZ-Lab/cpzai#3132
…, exact fits - Time under water counts only days below the peak; up/down capture use Morningstar's geometric per-period ratio; worst/best month run month-end to month-end; an equity value at or below zero ends the curve as a total loss. The Rust kernel matches (cargo tests added). - Regime breakdown labels each day from trailing volatility and the previous benchmark close, not from the day's own move. - certify: a missing beta or capacity scores the lowest band, NumPy numbers and booleans are accepted, a fractional max_drawdown raises. - factor_attribution: an exact fit reports NaN alpha t-stat and idiosyncratic Sharpe instead of rounding noise. Fixes CPZ-Lab/cpzai#3029 Fixes CPZ-Lab/cpzai#3047 Fixes CPZ-Lab/cpzai#3048 Fixes CPZ-Lab/cpzai#3069 Fixes CPZ-Lab/cpzai#3145 Fixes CPZ-Lab/cpzai#3177
…_search grid_search passes returns straight to cross_validate, which now accepts Polars and pandas frames, so it needs no conversion of its own. Keeps the grid_search body untouched next to the open grid_search fix (PR #7).
…h their published methods - HRP splits by inverse variance (Lopez de Prado 2016, PyPortfolioOpt) and handles one asset; HERC follows the dendrogram (Raffinot 2018, riskfolio-lib). - Quantum-inspired HRP reads solved positions the right way round; the heuristic is spectral seriation with swap refinement. - Risk parity uses cyclical coordinate descent (no NaN for stock-bond pairs). - NCO max-Sharpe raises when no tangency portfolio exists. - mean_cvar is an exact LP; native optimisers enforce gross caps through smooth epigraph variables, reject unsupported limits and raise on failed solves; a redundant long-only gross cap no longer stalls SLSQP. - alpha_risk_cost_optimize prices trades per unit traded and reports the Clarke, de Silva & Thorley transfer coefficient. - cvxpy optimisers raise on sector, factor and tracking-error limits; robust mean-variance uses the standard error of the annualised mean. - mean_risk_optimize accepts frames, needs max_risk for max_return. - entropy_pooling verifies its views. - OAS, Ledoit-Wolf (all targets), EWMA, Marchenko-Pastur and Gerber match sklearn, the authors' published code and riskfolio-lib; estimators, copulas and pre-selection raise on missing returns. Refs CPZ-Lab/cpzai#3016 #3017 #3019 #3020 #3046 #3049 #3051 #3079 #3124 #3126 #3131 #3137 #3144 #3146
…cored setting (sweep 11-25) Only None, NaN and inf mark a setting unscored. A string, array or bool score raises TypeError naming the setting instead of being skipped.
…p inputs, invented liquidity - certify: a max_drawdown equal to analytics.max_drawdown (a fraction, including -1.0 for a wipe-out) raises at any size, and a magnitude of 1 or less needs the analytics to confirm it as a percent. - Indicators: scalar guards are NaN-aware (a NaN in the window gives NaN, not 0, 50, -50 or 0.5) in CCI, z-scores, ROC, momentum, STC, MFI, OBV, Williams %R, stochastic, Fisher, ADX, KAMA and the regression R-squared. Flat prices give NaN in MFI, the Ultimate Oscillator, fast stochastic and Williams %R, as in RSI. - fundamental_factors: single-number caps need caps_at_start=True; caps given as series stay point in time. - turnover_analysis, sqrt/linear/Almgren-Chriss impact and capacity raise on a missing or non-positive ADV or volatility instead of using 1% of the book, 2% a day or a volatility of 1.0; without a cost model the cost is None, not 0. - A wiped-out curve too short for statistics still reports the total loss (NumPy and Rust); the regime breakdown counts a wipe-out. - momentum module pickles by name and carries the indicator docstring; the NumPy SMA is O(n); factor_attribution returns None, not NaN, for undefined statistics. - CHANGELOG: "Changed (may break callers)" section. Refs CPZ-Lab/cpzai#3177 Refs CPZ-Lab/cpzai#3039 Refs CPZ-Lab/cpzai#3045 Refs CPZ-Lab/cpzai#3047
- NCO max-Sharpe checks for a tangency portfolio only in the cluster-level problem. A cluster with a negative 1'Sigma^-1 mu is weighted negatively there, which flips it back, so it no longer raises; the error names NCO and the clusters and suggests only objective='min_variance'. - select_complete_assets returns the kept assets on their common complete window, so its output feeds the next step. - cvxpy optimisers apply a positive min_weight when long_only=True; cardinality_constrained_cvx raises on one and points to min_position. - mean_cvar names target_return and the highest attainable return when the target is out of reach. - QHRP split search uses a 2D prefix sum (same splits, 10x faster at 500 assets). - README, docs and rust/README.md stop claiming the Rust crate accelerates Ledoit-Wolf, EWMA, Marchenko-Pastur or HRP; CHANGELOG lists the new errors.
… corr/beta; impact and drawdown checks - CMO keeps a missing change NaN instead of a flat bar; CMF gives NaN for a missing high, low, close or volume instead of 0; Aroon gives NaN for a window holding a missing bar (argmax took the NaN as the extreme); NVI/PVI stay NaN after a missing bar instead of absorbing it; rolling correlation and beta give NaN instead of 0. - sqrt_impact and Almgren-Chriss raise a clear ValueError when volatility is omitted (was a TypeError from float(None)). - certify raises when the metrics drawdown contradicts the analytics one (for example -15 against -0.62); the tail-penalty test now passes the analytics drawdown so only the analytics differ. Refs CPZ-Lab/cpzai#3040 Refs CPZ-Lab/cpzai#3045 Refs CPZ-Lab/cpzai#3177
…r volatility sqrt, linear and Almgren-Chriss impact raised on a missing ADV even when nothing was traded or impact was not priced (impact_coefficient=0, or gamma = eta = 0). A spread-and-commission-only CostModel (as the alpha-risk-cost optimizer in PR #9 uses with estimate(0.0, 0.0, 0.0)) then failed. Those cases have zero impact and need no market inputs; turnover_analysis only asks for ADV and volatility when impact is priced. Priced impact still raises without them. Refs CPZ-Lab/cpzai#3045 Refs CPZ-Lab/cpzai#3070
The prefix-sum split search compared costs that tie in exact arithmetic but differ by summation rounding, so tied splits were broken by rounding (an equal-similarity block of 28 picked 21 where the loop picked 8). Take the first split within a relative 1e-9 of the minimum instead, and test it.
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.
Integrates the verified analytics, optimizer, model-selection, and rolling-risk fixes for cpz-quant 1.3.0. Preserves the original fix commits so the related pull requests can be recognized as merged.
Validation: 1,832 tests passed with 7 skips before installing quantum extras; the optional quantum suite then passed all 28 tests. Ruff and mypy pass. The wheel and source archive build and pass twine metadata validation. Combined SDK compatibility is being checked against the exact candidate wheel before publication.
GitHub Actions cannot start because the account is billing-locked; these checks were executed locally. See CHANGELOG for changed error handling and numerical definitions.
Includes #7, #8, #9, #10.