This handles the math behind portfolio diversification, from basic two-asset variance formulas through efficient frontier construction and risk contribution analysis. You'll reach for it when building portfolios, computing correlations, or explaining why holding 50 tech stocks isn't actually diversified. It covers minimum variance portfolios, diversification ratios, and factor-based approaches. The most useful bit is probably the risk contribution decomposition, which shows exactly which positions drive your portfolio volatility. One thing to know: it's grounded in the reality that correlations spike during crises, so the examples include stress-testing correlation matrices rather than pretending diversification always works when you need it.

skills.sh installs
769
GitHub stars
224
last updated
Aug 21, 2026

Install

$ npx -y skills add joellewis/finance_skills --skill diversification --agent claude-code

Installs into .claude/skills of the current project.

Files

Diversification

Core Concepts

Portfolio Variance (2 Assets)

For a portfolio of two assets with weights w_1 and w_2, volatilities sigma_1 and sigma_2, and correlation rho_12:

sigma^2_p = w_1^2 * sigma_1^2 + w_2^2 * sigma_2^2 + 2 * w_1 * w_2 * sigma_1 * sigma_2 * rho_12

Diversification benefit arises whenever rho_12 < 1, because the portfolio volatility will be less than the weighted average of individual volatilities.

Portfolio Variance (n Assets)

In matrix notation for n assets with weight vector w and covariance matrix Sigma:

sigma^2_p = w' * Sigma * w

This generalizes to any number of assets and captures all pairwise correlations.

Diversification Benefit

Portfolio volatility is strictly less than the weighted average of individual volatilities whenever any pairwise correlation is below 1:

sigma_p < Sigma(w_i * sigma_i) when rho_ij < 1 for some i,j

The lower the average correlation, the greater the diversification benefit.

Sponsors

Details

Repository
github.com/joellewis/finance_skills
Categories
DevOps & CI/CD, Finance & Trading
First seen
Jun 3, 2026

More from joellewis/finance_skills

All 84
1product-on-purpose avatariterate-lessons-logproduct-on-purpose/pm-skillsCreates a structured lessons learned entry for organizational memory. Use after an incident, a completed project, or a significant learning to record knowledge 767skills.sh installs
2getstream avatarstream-buildergetstream/agent-skillsThe framework-agnostic Stream builder (Steps 0-7 scaffold + enhance + Video audit), being extended to support app kinds beyond web. Use ONLY when the user expli759skills.sh installs
3alirezarezvani avatarquality-manager-qmralirezarezvani/claude-skillsSenior Quality Manager Responsible Person (QMR) for HealthTech and MedTech companies. Provides quality system governance, management review leadership, regulato755skills.sh installs
4mblode avatarscaffold-climblode/agent-skillsScaffolds a production-ready TypeScript CLI and npm package with ESM, a dual tsdown build (CLI binary plus typed library), vitest, oxlint and oxfmt via ultracit751skills.sh installs
5kunchenguid avatarno-mistakeskunchenguid/axiValidate your code changes through the no-mistakes pipeline - automated code review, tests, lint, docs, push, PR, and CI - before they reach upstream. Use when 750skills.sh installs
6cap-go avatarcapgo-release-managementcap-go/capgo-skillsGuides the agent through Capgo OTA release workflows including bundle uploads, compatibility checks, channels, cleanup, and encryption key setup. Use when manag749skills.sh installs