Conversation
…ariance Implements pairwise exponentially weighted moving covariance and cross-volatility between two return series, as requested in #81. - Finance.ewmCrossCov: EWMA covariance between two series using the same mean-corrected update rule as ewmCovMatrix. The two series are aligned on their shared keys; rows where either value is missing are dropped. Initialised with the full-sample covariance. - Finance.ewmCrossVol: signed square root of ewmCrossCov, giving cross-volatility in vol units. sign(vol) preserves the direction of co-movement; squaring recovers the covariance magnitude. Both functions accept the same com/span/halfLife/alpha decay parameters as all other EWM functions in Deedle.Math.Finance. Tests added: - ewmCrossCov(x, x) == ewmVar(x) (diagonal consistency) - ewmCrossCov(col0, col1) matches off-diagonal of ewmCovMatrix at last row - |ewmCrossVol|² == |ewmCrossCov| (magnitude) - sign(ewmCrossVol) == sign(ewmCrossCov) (sign preservation) Closes #81 Co-authored-by: Copilot <[email protected]>
Member
|
/repo-assist Given this arose from issue #81, if necessary also add C# extension methods for these and for any other missing operations |
Contributor
Author
|
✗ Repo Assist encountered failed, see workflow run. |
Member
|
/repo-assist Given this arose from issue #81, if necessary also add C# extension methods for these and for any other missing operations |
Contributor
Author
|
✗ Repo Assist encountered failed, see workflow run. |
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.
🤖 This is an automated pull request from Repo Assist, an AI assistant for this repository.
Closes #81
Summary
Adds two new functions to
Deedle.Math.Financefor computing pairwise exponentially weighted moving statistics between two return series:Finance.ewmCrossCov(x, y, ...)— EWMA covariance between two seriesFinance.ewmCrossVol(x, y, ...)— signed square root ofewmCrossCov, giving cross-volatility in vol unitsBoth accept the same
?com / ?span / ?halfLife / ?alphadecay parameters as all other EWM functions inDeedle.Math.Finance.Design
ewmCrossCovUses the same mean-corrected EWMA update rule as
ewmCovMatrix:This means
ewmCrossCov(x, x)is exactly equal toewmVar(x)(verified by test), andewmCrossCov(x, y)matches the off-diagonal element ofewmCovMatrixfor the two-column frame[x, y](also verified).Initialised with the full-sample covariance (consistent with how
ewmCovMatrixinitialises withStats.covMatrix). The two series are aligned on their shared keys; rows where either value is missing are dropped.ewmCrossVolDefined as
sign(cov) · √|cov|so that squaring recovers the magnitude of the covariance and the sign indicates the direction of co-movement (positive = co-move, negative = move in opposite directions).Test Status
All 41 tests pass (
dotnet test tests/Deedle.Math.Tests/Deedle.Math.Tests.fsproj -c Release), including 5 new tests:ewmCrossCov of series with itself equals ewmVarewmCrossCov between two columns matches off-diagonal of ewmCovMatrixewmCrossVol squared equals ewmCrossCov in magnitudeewmCrossVol preserves sign of ewmCrossCov