Repository navigation
[SDK] Add a member return correlation matrix #1201
Description
Summary
Compute the pairwise correlation of member return series produced by a composed run, so a composition can show whether its members diversify or move together.
Motivation
Correlation exists today only for simulated asset price paths (packages/strategies/src/correlated-paths.ts:56-94), never for strategy returns. Two members can each be sound in isolation yet rise and fall together, which is the risk a composition is meant to reveal. Without a return-correlation view, a user cannot tell a genuine diversifier from a duplicate position.
Proposed Solution
- Add a
correlationMatrix(memberReturns)function inpackages/strategies/src/composition/that takes the per-member return series from the composed runner ([SDK] Add the composed backtest runner and per-member attribution #1200) and returns a symmetric matrix ofDecimalcorrelation coefficients with a unit diagonal. - Handle zero-variance members explicitly by surfacing the correlation as undefined rather than NaN, consistent with the guarded division already used in
packages/strategies/src/risk-metrics.ts. - Reuse the existing
Decimalutilities; introduce no new dependency.
Scope
| Field | Value |
|---|---|
| Area | SDK |
| Protocol affected | None |
| Network | testnet |
| Breaking change? | No |
Alternatives Considered
- Compute correlation from simulated price paths rather than member returns. Rejected, because the quantity of interest is how the strategies behave, not how their underlying assets do.
- Add a full covariance module. Rejected as out of scope; a correlation matrix satisfies the composition view and can be extended later.
Acceptance Criteria
- A known input yields the expected matrix, including a perfectly correlated and a perfectly anti-correlated pair.
- A zero-variance member yields an explicit undefined entry, not NaN.
- The matrix is symmetric with a unit diagonal.
-
pnpm --filter @meridian/strategies testandnpx tsc --noEmitpass.
Additional Context
Depends on the composition interface, #1197, and the composed backtest runner, #1200, for the member return series it consumes. Part of the Meridian Strategies initiative.
Star the repo
Please star this repository before picking up this issue. It is a small ask that meaningfully helps the project reach more people.
Activity
camesenin commentedon Oct 19, 2026
@camesenin has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @camesenin to this issue.
liutingqiu commentedon Oct 20, 2026
@liutingqiu has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @liutingqiu to this issue.
Shalombonet commentedon Oct 20, 2026
@Shalombonet has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Shalombonet to this issue.
drips-wave commentedon Oct 20, 2026
Congratulations, @liutingqiu! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @liutingqiu: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
feat(strategies): add member return correlation matrix (drydocs#1201)
grantfox-oss commentedon Oct 20, 2026
🎉 This issue has been marked as completed on GrantFox!
@liutingqiu's PR #1211 was approved and merged by @collinsezedike.
🏆 @liutingqiu: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (140 total points). Track your full progress on GrantFox.
👏 Great work, @liutingqiu! Keep contributing to drydocs.
drips-wave commentedon Oct 20, 2026
This issue has been completed by @liutingqiu as part of the Stellar Wave Program's 10th Wave 🥳
😎 @liutingqiu: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.