# Send 投资组合分析技能 to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "financial-analysis-skill",
    "name": "投资组合分析技能",
    "source": "tencent",
    "type": "skill",
    "category": "数据分析",
    "sourceUrl": "https://clawhub.ai/wzratgit/financial-analysis-skill",
    "canonicalUrl": "https://clawhub.ai/wzratgit/financial-analysis-skill",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/financial-analysis-skill",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=financial-analysis-skill",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "INSTALLATION.md",
      "manifest.json",
      "NETWORK_SECURITY.md",
      "optimized_main.py",
      "optimized_risk_parity_skill.py",
      "README.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "financial-analysis-skill",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T17:17:57.732Z",
      "expiresAt": "2026-05-07T17:17:57.732Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=financial-analysis-skill",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=financial-analysis-skill",
        "contentDisposition": "attachment; filename=\"financial-analysis-skill-1.0.2.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "financial-analysis-skill"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/financial-analysis-skill"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/financial-analysis-skill",
    "downloadUrl": "https://openagent3.xyz/downloads/financial-analysis-skill",
    "agentUrl": "https://openagent3.xyz/skills/financial-analysis-skill/agent",
    "manifestUrl": "https://openagent3.xyz/skills/financial-analysis-skill/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/financial-analysis-skill/agent.md"
  }
}
```
## Documentation

### 概述

这是一个用于投资组合分析的技能，支持使用本地CSV数据进行风险平价组合分析，并提供文字报告和图表可视化。优化版本整合了滚动窗口调仓逻辑和回测功能。

重要说明：此技能仅使用本地CSV文件进行分析，不进行任何网络请求，不需要任何API密钥。

### 功能特性

✅ 投资组合分析（资产配置、风险评估、收益分析）
✅ 支持多种资产类型：股票、债券、商品等
✅ 本地CSV数据处理
✅ 文字报告生成
✅ 图表可视化（收益曲线、资产分布、风险指标等）
✅ 滚动窗口风险平价分析（使用历史一年数据，每月调仓）
✅ 避免未来数据（使用expanding窗口计算波动率）
✅ 回测功能（完整的回测流程）
✅ 无需API密钥（仅使用本地CSV数据）

### 数据源

本地CSV文件（中国市场数据）
不需要任何外部API密钥

### 安装依赖

pip install yfinance pandas numpy matplotlib seaborn plotly

### 1. 基本使用

分析投资组合

python financial_analysis.py --portfolio example_portfolio.json --output ./output

获取单个资产数据

python financial_analysis.py --symbol AAPL --period 1y

### 2. 滚动窗口风险平价分析

运行回测

python optimized_risk_parity_skill.py --csv "C:\\path\\to\\marketdata.csv" --output ./backtest_output

数据格式要求

CSV文件应包含日期列和收益率列
收益率数据应为百分比格式（如：1.5表示1.5%）
脚本会自动将百分比转换为实际收益率（除以100）
支持处理文本行和缺失值

### 3. 投资组合配置文件格式

创建一个JSON文件（如 my_portfolio.json）：

{
  "AAPL": 0.25,    # 苹果股票，权重25%
  "GOOGL": 0.20,   # 谷歌股票，权重20%
  "MSFT": 0.20,    # 微软股票，权重20%
  "AMZN": 0.15,    # 亚马逊股票，权重15%
  "TSLA": 0.20     # 特斯拉股票，权重20%
}

### 核心特点

避免未来数据：使用历史一年数据计算波动率
动态调仓：每月根据最新波动率重新计算权重
风险平价：各资产对组合风险贡献相等
回测验证：完整的回测流程，验证策略效果

### 分析流程

数据加载：加载CSV数据，处理百分比单位
滚动波动率：使用expanding窗口计算历史波动率
权重计算：基于波动率倒数计算风险平价权重
投资组合收益率：使用滚动权重计算每日收益率
绩效评估：计算总收益率、年化收益率、夏普比率等
可视化：生成收益曲线、资产配置、相关性等图表

### 输出文件

分析报告：rolling_risk_parity_report.txt
详细数据：rolling_risk_parity_data.json
可视化图表：

rolling_risk_parity_returns.png - 收益曲线图
rolling_risk_parity_allocation.png - 资产配置饼图
rolling_risk_parity_correlation.png - 相关性热力图
rolling_asset_returns_comparison.png - 资产收益对比图
rolling_weight_changes.png - 滚动权重变化图

### 报告内容

投资组合概览
收益分析（总收益、年化收益）
风险指标（波动率、最大回撤、夏普比率）
资产配置分析
相关性分析
滚动权重变化
可视化图表
投资建议

### 配置

此技能不需要任何API密钥配置。只需要提供本地CSV文件路径即可。

### 示例输出

中国市场滚动风险平价组合分析报告
============================================================
生成时间: 2026-02-26 10:20:04
数据来源: C:\\Users\\wu_zhuoran\\.openclaw\\workspace\\data\\marketdata.csv
数据时间范围: 2015-03-23 至 2026-02-25
数据点数: 2656
滚动窗口: 252个交易日（约1年）
调仓频率: 每月

平均投资组合配置:
  五年期国债 (TF.CFE): 46.04% (波动率: 2.46%)
  十年期国债 (T.CFE): 32.55% (波动率: 3.61%)
  沪铜 (CU.SHF): 9.33% (波动率: 17.87%)
  沪金 (AU.SHF): 12.09% (波动率: 14.88%)

收益指标:
  总收益率: 44.78%
  年化收益率: 3.57%

风险指标:
  年化波动率: 3.76%
  最大回撤: -9.48%
  夏普比率: 0.42

### 滚动窗口计算

使用expanding()窗口而非rolling()窗口
确保不使用未来数据
最小窗口大小为252个交易日（约1年）

### 权重计算

基于波动率倒数加权：权重 = (1/波动率) / ∑(1/波动率)
每月调仓，动态调整权重
使用前一天的权重计算当日收益率

### 回测验证

完整的回测流程
避免数据泄露
提供详细的绩效指标

### 注意事项

确保数据质量，处理缺失值和异常值
滚动窗口大小可根据实际情况调整
调仓频率可根据市场情况调整
考虑交易成本对回测结果的影响
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: wzratgit
- Version: 1.0.2
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-04-30T17:17:57.732Z
- Expires at: 2026-05-07T17:17:57.732Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/financial-analysis-skill)
- [Send to Agent page](https://openagent3.xyz/skills/financial-analysis-skill/agent)
- [JSON manifest](https://openagent3.xyz/skills/financial-analysis-skill/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/financial-analysis-skill/agent.md)
- [Download page](https://openagent3.xyz/downloads/financial-analysis-skill)