Skip to content

fix: unify maxDrawdown sign convention - #1222

Merged
collinsezedike merged 1 commit into
drydocs:mainfrom
Deevhyne1023:fix/issue-1044-bug-maxdrawdown-uses-opposite-sign-conventions
Oct 25, 2026
Merged

collinsezedike merged 1 commit into
drydocs:mainfrom
Deevhyne1023:fix/issue-1044-bug-maxdrawdown-uses-opposite-sign-conventions

Conversation

@Deevhyne1023

@Deevhyne1023 Deevhyne1023 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

The report field documents maxDrawdown as a non-negative fraction. risk-metrics now returns the decline magnitude under the same convention, with the field documentation and tests updated.

Validation: pnpm --filter @meridian/strategies test passed with 743 tests.

Closes #1044

@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@Deevhyne1023 is attempting to deploy a commit to the Collins' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@Deevhyne1023 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Deevhyne1023 Test, Lint & Typecheck, and Commit Messages all fail. computeRiskMetrics calls a function that does not exist, and the doc-comment rewrite and typos are unrelated to the issue. Add Closes #1044 to the PR body, shorten the commit header to 72 characters or fewer, and run pnpm --filter @meridian/strategies test, npx tsc --noEmit, and pnpm format before pushing. See the inline notes.

Comment thread packages/strategies/src/risk-metrics.ts Outdated
options.varianceMode ?? "population"
),
valueAtRisk: valueAtRisk(returns, options.confidenceLevel ?? 0.95),
valueAtRisk: valueAtRIsk(returns, options.confidenceLevel ?? 0.95),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

valueAtRIsk is not defined. This is the compile error that fails Test and Lint & Typecheck; use valueAtRisk.

Comment thread packages/strategies/src/risk-metrics.ts Outdated
const threshold = sorted[Number(clamped) - 1];
if (threshold === undefined) {
throw new RangeError("valueAtRisk rank fell outside the series");
throw new RangeError("valueAtRIsk rank fell outside the series");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Typo in the error message: valueAtRIsk should be valueAtRisk.

Comment thread packages/strategies/src/risk-metrics.ts Outdated
* `(1 - confidenceLevel)` lower tail reaches, and a negative result means even
* that tail stayed above break-even.
* "(1 - confidenceLevel)" lower tail reaches, and a negative result means even
* that tail stayed above break-ven.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Typo: break-ven should be break-even.

Comment thread packages/strategies/src/risk-metrics.ts Outdated
* - Arithmetic runs at scale 18, or the widest input scale when that is
* larger, so no input is rounded before an operation.
* - `riskFreePerPeriod` is a per-period rate subtracted from the mean return.
* - "riskFreePerPeriod" is a per-period rate subtracted from the mean return.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This block and the other backtick replacements are unrelated to the sign-convention fix and make the comments harder to read. Revert them.

@Deevhyne1023
Deevhyne1023 force-pushed the fix/issue-1044-bug-maxdrawdown-uses-opposite-sign-conventions branch from 0f1c1ca to 0ada7c8 Compare October 22, 2026 03:40

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Deevhyne1023 The obfuscated payload has been removed. The compile error remains. risk-metrics.ts uses valueAtRIsk at lines 129 and 168 and break-ven at line 101. The unrelated doc-comment rewrite is also still present.

@collinsezedike collinsezedike changed the title fix: unify maxDrawdown sign convention across report and risk-metrics fix: unify maxDrawdown sign convention Oct 25, 2026
@collinsezedike
collinsezedike force-pushed the fix/issue-1044-bug-maxdrawdown-uses-opposite-sign-conventions branch from 1bcea29 to ee1d434 Compare October 25, 2026 08:56

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Restored the surrounding risk-metrics documentation, fixed the valueAtRisk identifier and break-even typo, removed branch_structure.json, and kept the maxDrawdown magnitude change with matching tests. The strategies suite passes with 743 tests.

@collinsezedike
collinsezedike merged commit 9c76c89 into drydocs:main Oct 25, 2026
10 of 11 checks passed
@collinsezedike

Copy link
Copy Markdown
Collaborator

@Deevhyne1023 Thank you for your contribution, and please star the repository if you found Meridian useful.

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.

[Bug] maxDrawdown uses opposite sign conventions in report.ts and risk-metrics.ts

2 participants