Skip to content

[Repo Assist] Add Finance.ewmCrossCov and Finance.ewmCrossVol for pairwise EWMA covariance#699

Merged
dsyme merged 2 commits intomasterfrom
repo-assist/feature-ewm-cross-covariance-issue-81-9acf89feb5cb52a2
Apr 4, 2026
Merged

[Repo Assist] Add Finance.ewmCrossCov and Finance.ewmCrossVol for pairwise EWMA covariance#699
dsyme merged 2 commits intomasterfrom
repo-assist/feature-ewm-cross-covariance-issue-81-9acf89feb5cb52a2

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Apr 4, 2026

🤖 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.Finance for computing pairwise exponentially weighted moving statistics between two return series:

  • Finance.ewmCrossCov(x, y, ...) — EWMA covariance between two series
  • Finance.ewmCrossVol(x, y, ...) — signed square root of ewmCrossCov, giving cross-volatility in vol units

Both accept the same ?com / ?span / ?halfLife / ?alpha decay parameters as all other EWM functions in Deedle.Math.Finance.


Design

ewmCrossCov

Uses the same mean-corrected EWMA update rule as ewmCovMatrix:

cov_t = (1−α)·cov_{t−1} + α·(x_t − mean_x_{t−1})·(y_t − mean_y_{t−1})

This means ewmCrossCov(x, x) is exactly equal to ewmVar(x) (verified by test), and ewmCrossCov(x, y) matches the off-diagonal element of ewmCovMatrix for the two-column frame [x, y] (also verified).

Initialised with the full-sample covariance (consistent with how ewmCovMatrix initialises with Stats.covMatrix). The two series are aligned on their shared keys; rows where either value is missing are dropped.

ewmCrossVol

Defined 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:

Test Purpose
ewmCrossCov of series with itself equals ewmVar Diagonal consistency
ewmCrossCov between two columns matches off-diagonal of ewmCovMatrix Consistency with existing multi-series API
ewmCrossVol squared equals ewmCrossCov in magnitude Mathematical identity
ewmCrossVol preserves sign of ewmCrossCov Sign correctness

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4ea8c81959909f40373e2a5c2b7fdb54ea19e0a5

…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]>
@dsyme dsyme marked this pull request as ready for review April 4, 2026 14:30
@dsyme
Copy link
Copy Markdown
Member

dsyme commented Apr 4, 2026

/repo-assist Given this arose from issue #81, if necessary also add C# extension methods for these and for any other missing operations

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Apr 4, 2026

✗ Repo Assist encountered failed, see workflow run.

@dsyme
Copy link
Copy Markdown
Member

dsyme commented Apr 4, 2026

/repo-assist Given this arose from issue #81, if necessary also add C# extension methods for these and for any other missing operations

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Apr 4, 2026

✗ Repo Assist encountered failed, see workflow run.

@dsyme dsyme merged commit c139848 into master Apr 4, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/feature-ewm-cross-covariance-issue-81-9acf89feb5cb52a2 branch April 4, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide simpler-to-use extension methods for time series data

1 participant