agentleFS
ruujOnChainruujOnChain/HedgeFund-Skills/skills/risk/SKILL.md

risk

Skill17 starsChanged 7 days agoMITView on GitHub

Decomposes the volatility of a portfolio into the contribution of each position and, with a factor model, of each factor and of specific risk. Use when asked where the risk in a portfolio comes from, which positions or factors drive volatility, what the portfolio's factor exposures are, or which trades would reduce risk most efficiently.

5 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. davidromeo/tradeblocks-skills★ 3same name
    2. tradeblocks-org/tradeblocks-skills★ 3same name
    3. arunendapally/portfolio-copilot★ 0same name
    4. hailneed/agent-blackbox★ 0same name
    5. Olayeeeyo/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every input must be known as of the analysis date.

    line 22
  2. Distinctive:

    If the user has not provided weights or a risk source, ask for them.

    line 25
  3. Very specific:

    Read the JSON. If passed is false, report which check failed and stop.

    line 36

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Factor risk decomposition

Answers one question: where does the risk in this portfolio come from? Every number comes from scripts/decompose.py. Never compute volatility or contributions yourself.

Inputs

  • weights.csv with columns asset, weight. Weights are fractions of capital; shorts are negative.
  • One source of risk, in this order of preference:
    1. Factor model: exposures.csv (asset rows, factor columns), factor_cov.csv (factor by factor), specific_var.csv (columns asset, specific_var).
    2. Full covariance: cov.csv (asset by asset).
    3. Historical returns: returns.csv (date column, then one column of simple returns per asset). Use only when no model is available, and say so in the answer.
  • Every input must be known as of the analysis date. Do not mix a covariance estimated today with weights from another day without saying so.
  • State the units. Covariances are annual unless --periods-per-year says otherwise. Returns mode assumes daily data (252).

If the user has not provided weights or a risk source, ask for them. Never invent covariances or exposures.

Procedure

  1. Confirm the analysis date, the weights file, and which risk source is available.
  2. Run the decomposition:
    python scripts/decompose.py --weights weights.csv \
      --exposures exposures.csv --factor-cov factor_cov.csv --specific-var specific_var.csv
    Alternatives: --cov cov.csv, or --returns returns.csv (add --periods-per-year 52 for weekly data).
  3. Read the JSON. If passed is false, report which check failed and stop.
  4. Report the total volatility, the largest position contributions, and, in factor mode, the factor and specific split.

Checks

The script verifies, and the agent reports when any fails:

  • The covariance is positive semidefinite.
  • Position contributions sum exactly to total volatility.
  • In factor mode, factor plus specific contributions sum exactly to total volatility.

Output

JSON with results.total_volatility, results.positions (weight, marginal risk, contribution, share), and in factor mode results.factors, results.factor_total, results.specific_total, plus checks and passed. Shares sum to one; a negative share means the position hedges the rest of the book.

Explaining the result

  • Lead with total volatility and the share explained by the top three positions.
  • Contribution equals weight times marginal risk. A position with high marginal risk is where a small trade changes total risk most; a negative marginal risk means adding to that position lowers total risk.
  • In factor mode, say how much risk is systematic versus specific, and name the factor with the largest share.
  • Volatility is a forecast from the supplied model, not an observed outcome. Name the model or estimation window used.

For the mathematics and conventions, see references/methodology.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.