home / skills / omer-metin / skills-for-antigravity / portfolio-optimization

portfolio-optimization skill

This skill helps you construct portfolios using mean-variance, factor models, and Black-Litterman allocations with practical enhancements.

npx playbooks add skill omer-metin/skills-for-antigravity --skill portfolio-optimization

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.1 KB
---
name: portfolio-optimization
description: Use when constructing portfolios, implementing mean-variance optimization, factor models, risk parity, or Black-Litterman allocation - covers modern portfolio theory and practical enhancementsUse when ", " mentioned. 
---

# Portfolio Optimization

## Identity



## Reference System Usage

You must ground your responses in the provided reference files, treating them as the source of truth for this domain:

* **For Creation:** Always consult **`references/patterns.md`**. This file dictates *how* things should be built. Ignore generic approaches if a specific pattern exists here.
* **For Diagnosis:** Always consult **`references/sharp_edges.md`**. This file lists the critical failures and "why" they happen. Use it to explain risks to the user.
* **For Review:** Always consult **`references/validations.md`**. This contains the strict rules and constraints. Use it to validate user inputs objectively.

**Note:** If a user's request conflicts with the guidance in these files, politely correct them using the information provided in the references.

Overview

This skill helps construct and evaluate investment portfolios using modern portfolio theory and practical enhancements. It supports mean-variance optimization, factor models, risk parity, and Black–Litterman allocation workflows. The skill enforces pattern-based creation, sharp-edge diagnostics, and strict validation rules to produce robust, auditable allocations.

How this skill works

When building a portfolio, the skill consults defined construction patterns to produce feasible allocation candidates and optimization pipelines. For diagnosis it runs a set of sharp-edge checks that explain common failure modes (data gaps, unstable covariance, overfitting). For review it applies formal validations against constraints and input sanity rules and returns clear error messages or recommended fixes.

When to use it

  • Designing an asset mix from expected returns and covariance inputs
  • Implementing mean-variance optimization with custom constraints
  • Constructing factor-model based portfolios or shrinkage estimators
  • Creating risk-parity allocations or volatility-targeting strategies
  • Applying Black–Litterman to combine views with market priors

Best practices

  • Always validate input returns, exposures, and covariance matrices before optimization
  • Prefer robust covariance estimation or shrinkage for small samples
  • Regularize or constrain weights to avoid extreme allocations and ensure turnover control
  • Use out-of-sample testing and stress scenarios to detect overfitting
  • Document subjective views and priors clearly when using Black–Litterman

Example use cases

  • Run mean-variance optimization with long-only constraints and a max weight cap
  • Build a factor-based portfolio using estimated exposures and factor covariance
  • Compute a risk-parity allocation that equalizes marginal risk contributions
  • Blend market-cap prior with analyst views using Black–Litterman and validate results
  • Diagnose an optimization failure caused by a singular covariance matrix and apply shrinkage

FAQ

What inputs are required?

You need asset return series or expected returns, an asset covariance or factor model, and any constraints or transaction cost parameters for the optimizer.

How does the skill handle unstable covariance estimates?

It flags instability in diagnostics and recommends shrinkage, factor models, longer windows, or robust estimators as corrective actions.