asset-allocation
它能做什么
这项技能解释在多项资产之间分配资金的主要方法,并说明如何运行内置的投资组合优化器。适合希望理解配置理论并将其付诸实践的投资者和分析师。
适用场景
- ✓当你想用清晰的方法把投资组合分配到多项资产上的时候。
- ✓当你想把市场观点与基准配置结合起来的时候。
- ✓当你想使用优化器并把输出保存到配置文件的时候。
技能链接
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/asset-allocation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为这五只 ETF 构建风险均衡的配置,解释所用的方法,并把权重写入配置文件。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会解释所选的方法,例如均值方差或风险预算,包括其优缺点。然后它会使用你的约束条件运行对应的优化器,并把得出的权重写入配置文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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 5 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 |
turnover_aware |
Turnover-Aware | Mean-variance utility with an L1 penalty on weight changes vs the previous rebalance | When trading costs matter; tune turnover_penalty to your data frequency |
1. equal_volatility
{
"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
{
"optimizer": "risk_parity",
"optimizer_params": {
"
常见问题
单纯的均值方差优化够用吗?
技能提醒不要单独使用它,因为结果对输入非常敏感,并建议加入约束条件。
什么是 Black-Litterman?
它从市场基准出发,并用你对特定资产的观点对其进行调整。
权重可以直接使用吗?
可以写入配置文件,但在任何实际使用之前都应该先审核。
详情
作者的原始描述
Asset allocation theory and optimizer usage — MPT / Black-Litterman / risk budgeting / all-weather strategy, including guides for 5 optimizers and rebalancing rules.
repo: HKUDS/Vibe-Trading
热度
- GitHub 星标
- 37k
- 排名
- #7498
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …