Skip to content

fix(features): compute Roll spread with current-window covariance - #85

Merged
stefan-jansen merged 4 commits into
mainfrom
codex/roll-spread-window-covariance
Oct 15, 2026
Merged

stefan-jansen merged 4 commits into
mainfrom
codex/roll-spread-window-covariance

Conversation

@stefan-jansen

@stefan-jansen stefan-jansen commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #84. Supersedes the Roll-spread portion of #71.

Calculate serial covariance over the same current window, rather than averaging products whose points were each demeaned by different trailing windows. Keep the corrected period+1 lookback metadata. Preserve the original source correction and authorship.

Also keep missing covariance windows undefined: an actual CSV NaN price previously made the estimator report zero spread, unlike an empty CSV field. Guard NaN covariance before nonnegative clipping. Finite nonnegative covariance still produces zero as intended; unknown windows produce null.

At head 7c3d66a, after incorporating qualified main eed81dc, all 39 microstructure tests pass. Sixteen permanent real-CSV cases cover periods 1/2/4/7 and eager/lazy workflows. Before the additional producer repair, all eight NaN cases failed and all eight empty-field controls passed. The oracle uses NumPy's independently centered covariance with ddof=0. The original finite-window regression also uses that independent implementation.

The full suite passes 4,215 tests with 57 intentional deselections. Ruff, formatting, ty, all-file hooks, lock validation, package build/import, twine metadata checks and strict MkDocs pass. The isolated built wheel passes the complete public CSV-gap reproduction. Fresh hosted qualification is required before merge. Earlier checks remain pinned to original submitted revision b6ad633.

Numerical and missing-value behavior changes warrant inclusion in the eventual qualified patch release. This PR does not publish a release or deploy documentation.

AI assistance: Codex reproduced the public CSV behavior, inspected source and overlap, implemented the focused missing-window repair and permanent independent regressions, ran checks and drafted this description. Original Cursor Agent source-fix authorship is retained; the lookback and supplemental repair commits remain separately attributed.

cursoragent and others added 2 commits October 10, 2026 05:39
The estimator subtracted each bar's own trailing mean and then averaged
those products, which is not the covariance of the current window. The
spread now uses E[xy] - E[x]E[y] over that window.

Co-authored-by: quantum-like <[email protected]>
The registered warm-up was twice the window because the old estimator
nested two rolling means. The window covariance is first defined one bar
after the lag is available.

Co-authored-by: quantum-like <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@stefan-jansen
stefan-jansen merged commit 828d594 into main Oct 15, 2026
31 checks passed
@stefan-jansen
stefan-jansen deleted the codex/roll-spread-window-covariance branch October 15, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: compute Roll spread from covariance within the current window

3 participants