Skip to main content
ClaudeWave
Skill12k repo starsupdated today

asset-allocation

This skill provides frameworks and implementation guidance for portfolio construction, covering Modern Portfolio Theory, Black-Litterman model adjustments to market equilibrium, risk budgeting allocation methods, and all-weather diversification strategies. Use this when designing asset allocation policies, implementing portfolio optimizers, or converting theoretical allocation approaches into concrete configuration settings for automated trading systems.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading /tmp/asset-allocation && cp -r /tmp/asset-allocation/agent/src/skills/asset-allocation ~/.claude/skills/asset-allocation
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Asset Allocation and Portfolio Optimization

## Overview

From asset allocation theory to practical implementation, this skill covers classical frameworks (MPT, BL, risk budgeting, all-weather) and the usage of the four optimizers built into this system. The output can be written directly into `config.json`.

## Asset Allocation Theory

### 1. Modern Portfolio Theory (MPT, Markowitz)

**Core idea**: maximize expected return for a given level of risk (the efficient frontier).

```
Optimization problem:
min  w'Σw              (portfolio variance)
s.t. w'μ = target_return
     Σw = 1
     w ≥ 0              (no shorting)
```

| Advantages | Disadvantages |
|------|------|
| Mathematically rigorous | Extremely sensitive to inputs (garbage in, garbage out) |
| Efficient frontier is visualizable | Concentrated-allocation problem (often produces extreme weights) |
| Foundational framework | Assumes normality and ignores fat tails |

**Practical advice**: do not use raw MPT directly. Add constraints (upper/lower bounds, sector limits) or use a regularized version.

### 2. Black-Litterman Model

**Core idea**: start from market equilibrium and incorporate investor views.

```
Steps:
1. Reverse-imply market equilibrium returns: π = δΣw_mkt
2. Build the view matrices: P (selection matrix), Q (view returns), Ω (view uncertainty)
3. Blend the posterior: μ_BL = [(τΣ)^-1 + P'Ω^-1 P]^-1 [(τΣ)^-1 π + P'Ω^-1 Q]
4. Run Markowitz optimization using posterior μ_BL
```

**Example views**:
- Absolute view: "China A-shares will return 10% over the next year"  → `P=[1,0,0], Q=[0.10]`
- Relative view: "China A-shares will outperform US equities by 5%"   → `P=[1,-1,0], Q=[0.05]`

**Parameter guidance**:
- `τ` (uncertainty scaling): `0.025-0.05`
- `Ω`: set according to view confidence, where higher confidence = smaller variance

### 3. Risk Budgeting

**Core idea**: allocate by risk contribution rather than by capital share.

```
Risk contribution: RC_i = w_i × (Σw)_i / σ_p
Target: RC_i / σ_p = budget_i  (for all i)
```

| Strategy | Risk Budget | Best Use Case |
|------|---------|---------|
| Equal risk contribution | Each asset 1/N | When you do not know which asset is best |
| Equity-tilted risk budget | Stocks 60%, bonds 30%, commodities 10% | When you want equities to contribute more risk |
| Dynamic risk budget | Adjust dynamically by signal strength | When you have market-timing ability |

### 4. All-Weather Strategy

**Bridgewater framework**: allocate risk equally across economic environments.

```
Economic environment   Asset allocation
─────────              ─────────
Growth rising          Equities + commodities + corporate bonds
Growth falling         Government bonds + inflation-protected bonds
Inflation rising       Commodities + inflation-protected bonds + EM debt
Inflation falling      Equities + government bonds

Simplified allocation example for China-focused portfolios:
- 30% CSI 300 / CSI 500
- 40% government bonds / credit bonds
- 15% gold
- 15% commodities / REITs
```

## Guide to the 4 Optimizers

### Overview of the Built-In Optimizers

Configure them in `config.json` through `optimizer` and `optimizer_params`:

| optimizer | Display Name | Core Idea | Best Use Case |
|-----------|--------|---------|---------|
| `equal_volatility` | Equal Volatility | Allocate weights by inverse volatility | Simple and effective baseline |
| `risk_parity` | Risk Parity | Equalize risk contribution while accounting for correlation | Long-term robust allocation |
| `mean_variance` | Mean-Variance | Maximize Sharpe ratio or minimize variance | When return forecasts are available |
| `max_diversification` | Maximum Diversification | Maximize the diversification ratio | When pursuing a low-correlation portfolio |

### 1. `equal_volatility`

```json
{
  "optimizer": "equal_volatility",
  "optimizer_params": {
    "lookback": 60
  }
}
```

**Principle**: `w_i = (1/σ_i) / Σ(1/σ_j)`

| Parameter | Default | Description |
|------|--------|------|
| lookback | 60 | Volatility calculation window (trading days) |

**Advantages**: simple and fast, no return forecast required, no correlation matrix required.  
**Disadvantages**: ignores cross-asset correlation.

### 2. `risk_parity`

```json
{
  "optimizer": "risk_parity",
  "optimizer_params": {
    "lookback": 60
  }
}
```

**Principle**: solve for weights such that each asset contributes the same amount of risk.

| Parameter | Default | Description |
|------|--------|------|
| lookback | 60 | Covariance-matrix estimation window |

**Advantages**: accounts for correlation, spreads risk more evenly, and is robust over long horizons.  
**Disadvantages**: requires iterative solving and is sensitive to covariance estimates.

### 3. `mean_variance`

```json
{
  "optimizer": "mean_variance",
  "optimizer_params": {
    "lookback": 60,
    "risk_free": 0.0
  }
}
```

**Principle**: Markowitz optimization that maximizes the Sharpe ratio.

| Parameter | Default | Description |
|------|--------|------|
| lookback | 60 | Window for estimating means and covariances |
| risk_free | 0.0 | Risk-free rate (annualized) |

**Advantages**: theoretically optimal (if inputs are accurate).  
**Disadvantages**: extremely sensitive to inputs, prone to extreme weights, and often performs poorly out of sample.  
**Recommendation**: do not make `lookback` too short (`<30` easily overfits), and add upper/lower weight constraints.

### 4. `max_diversification`

```json
{
  "optimizer": "max_diversification",
  "optimizer_params": {
    "lookback": 60
  }
}
```

**Principle**: maximize `DR = (w'σ) / σ_p` (the diversification ratio).

| Parameter | Default | Description |
|------|--------|------|
| lookback | 60 | Calculation window |

**Advantages**: does not require return forecasts and seeks true diversification.  
**Disadvantages**: effectiveness is limited in highly correlated environments.

### Optimizer Selection Decision Tree

```
Do you have return forecasts?
├── Yes → mean_variance (reme
vibe-tradingSkill

Professional finance research toolkit — backtesting (7 engines + benchmark comparison panel), factor analysis, Alpha Zoo (452 pre-built alphas across qlib158/alpha101/gtja191/academic), options pricing, 77 finance skills, 29 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 7 data sources (tushare, yfinance, okx, akshare, mootdx, ccxt, futu).

adr-hshareSkill

ADR/H-share/A-share cross-listing premium analysis — track pricing gaps between US-listed ADRs, HK-listed H-shares, and A-shares for arbitrage signals, dual-listing valuation, and delisting risk assessment.

akshareSkill

AKShare financial data aggregator (18k+ stars). Free, no API key. Covers A-shares, US, HK, futures, macro, forex. Primary fallback for tushare and yfinance.

alpha-zooSkill

Browse and bench the bundled alpha zoos — prebuilt cross-sectional factor libraries (Kakushadze 101, GTJA 191, Qlib 158, Fama-French / Carhart). Use when the user asks "which alphas exist", wants metadata on a named alpha, or wants to run IC/IR on a whole zoo over a universe.

ashare-pre-st-filterSkill

A 股 ST/*ST 风险预测框架 — 基于最新中报/三季报或业绩预告/快报,预测下一财年是否会因营收、利润、净资产、分红不达标而被风险警示,并将新浪监管处罚记录作为独立证据面纳入风险等级。仅适用于 A 股,不预测财务造假。

backtest-diagnoseSkill

Diagnose failed or underperforming backtests, locate the root cause, and fix the issue

behavioral-financeSkill

Behavioral finance applications: theories of overreaction and underreaction, behavioral explanations for momentum and reversal, investor sentiment cycles, cognitive-bias checklists, and debiasing quantitative strategies.

candlestickSkill

Candlestick pattern recognition engine, pure pandas vectorized implementation of 15 classic candlestick patterns (5 single-candle + 5 double-candle + 4 triple-candle + 1 trend confirmation), generating a composite signal from bullish/bearish pattern scores.