Skip to content

[DOC] Explain asset ordering in corr_to_cov - #783

Open
yqia03 wants to merge 1 commit into
PyPortfolio:mainfrom
yqia03:docs/corr-to-cov-asset-order
Open

yqia03 wants to merge 1 commit into
PyPortfolio:mainfrom
yqia03:docs/corr-to-cov-asset-order

Conversation

@yqia03

@yqia03 yqia03 commented Nov 30, 2026

Copy link
Copy Markdown

Summary

corr_to_cov uses standard deviations in matrix order, including when the input is a pandas Series with asset labels. Document the positional behavior and show how to select the Series values in correlation-matrix order.

- cov = corr_to_cov(corr, stdevs)
+ cov = corr_to_cov(corr, stdevs.loc[corr.columns])

Evidence

  • Given a correlation matrix ordered A, B and standard deviations supplied as B = 0.30, A = 0.10, passing the Series directly gives diagonal variances [0.09, 0.01]. The documented call gives [0.01, 0.09].
  • The fixture-based round-trip test uses the documented pattern with a reversed Series. All 26 tests in tests/test_risk_models.py pass, and the rendered example runs successfully.
  • Ruff lint and format checks pass. The Sphinx HTML build reports the same five diagnostics as the baseline.

Merge Impact

Documentation and a fixture-based test. Both are independently reversible.

AI Assistance

OpenAI Codex investigated the documentation gap, prepared the docs, test and description, and ran the local checks. No personal review by the account owner is claimed.

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.

1 participant