financeby mkurman
Pyportfolioopt
mkurman/pyportfolioopt
Portfolio optimization library: mean-variance, Black-Litterman, CVaR optimization, risk parity, Hierarchical Risk Parity (HRP), and CLA. Factor models, shrinkage estimators, and ex-ante risk analysis.
What it changes
Passed 22 of 23 test cases with the skill, and 18 of 23 without it.
Without skill78%
With skill96%
Checks it passed that the model alone missed
- The installation command specifies uv pip install PyPortfolioOpt.
- The script applies pct_change to raw prices before passing data to HRPOpt.
- The response specifies uv pip install PyPortfolioOpt for package installation.
and 1 more in the full report
4 fixed18 passed either way1 still failing0 broke
- Pass-rate lift
- +17 pp
- Tokens
- -3%
- Agent turns
- 0%
- Response time
- -25%
Model gemini-3.6-flashMeasured 8/21/2026v122 of 23 cases passed with skill
See it in action
One of 4 test cases the skill fixed. Same model, same prompt, with and without the skill.
PromptWhat is the preferred package manager installation command for installing PyPortfolioOpt?
What was checked, without and with the skill| Checked | Without skill | With skill |
|---|
| The installation command specifies uv pip install PyPortfolioOpt. | Missed | Passed |
|---|
What's inside
The instructions your model reads when the skill loads.
SKILL.md39 linessingle file
Overview
PyPortfolioOpt implements mean-variance optimization, Black-Litterman, CVaR optimization, risk parity, Hierarchical Risk Parity (HRP), and CLA. Handles asset allocation with factor models and ex-ante risk decomposition.
Installation
uv pip install PyPortfolioOpt
Max Sharpe Portfolio
import yfinance as yf
from pypfopt import EfficientFrontier, risk_models, expected_returns
prices = yf.download(["AAPL", "MSFT", "GOOGL"], start="2022-01-01")["Close"]
mu = expected_returns.mean_historical_return(prices)
S = risk_models.sample_cov(prices)
ef = EfficientFrontier(mu, S)
weights = ef.max_sharpe()
print(ef.clean_weights())
perf = ef.portfolio_performance()
print(f"Return: {perf[0]:.2%}, Vol: {perf[1]:.2%}, Sharpe: {perf[2]:.2f}")
HRP
from pypfopt import HRPOpt
returns = prices.pct_change().dropna()
hrp = HRPOpt(returns)
weights = hrp.optimize()
References
Track record
Benchmark
22 / 23
test cases passed, vs 18 / 23 without
Adoption
- Users
- 0
- Times used
- 0
Safety and source details
SkillSafety
✓ 3 of 3 passed✓Code scan15 of 15 checks clean
0 critical · 0 warning · 0 info — scanner v4 — 8/3/2026
View 15 scanner checks
live_secretremote_code_executionreverse_shelldata_exfiltrationssrf_metadataagent_snoopinganti_refusaldestructive_commandsobfuscated_unicodeunicode_homoglyphopaque_blobsuspicious_urltool_overreachtrigger_abuseprompt_injection_phrasing
✓IntentSafe
LLM judge · does the skill do what it claims
✓ContentClean
LLM judge · policy & harmful-content review
Source
ImportedLicense MITImported 8/3/2026Version v1