← All skills
Tencent SkillHub · Data Analysis

金融分析技能

利用免费数据源进行多资产投资组合的风险平价分析、动态调仓和回测,提供文字报告与图表可视化。

skill openclawclawhub Free
0 Downloads
0 Stars
0 Installs
0 Score
High Signal

利用免费数据源进行多资产投资组合的风险平价分析、动态调仓和回测,提供文字报告与图表可视化。

⬇ 0 downloads ★ 0 stars Unverified but indexed

Install for OpenClaw

Quick setup
  1. Download the package from Yavira.
  2. Extract the archive and review SKILL.md first.
  3. Import or place the package into your OpenClaw setup.

Requirements

Target platform
OpenClaw
Install method
Manual import
Extraction
Extract archive
Prerequisites
OpenClaw
Primary doc
SKILL.md

Package facts

Download mode
Yavira redirect
Package format
ZIP package
Source platform
Tencent SkillHub
What's included
manifest.json, optimized_main.py, optimized_risk_parity_skill.py, README.md, SKILL.md, 优化使用指南.md

Validation

  • Use the Yavira download entry.
  • Review SKILL.md after the package is downloaded.
  • Confirm the extracted package contains the expected setup assets.

Install with your agent

Agent handoff

Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.

  1. Download the package from Yavira.
  2. Extract it into a folder your agent can access.
  3. Paste one of the prompts below and point your agent at the extracted folder.
New install

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

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.

Trust & source

Release facts

Source
Tencent SkillHub
Verification
Indexed source record
Version
1.0.0

Documentation

ClawHub primary doc Primary doc: SKILL.md 17 sections Open source page

概述

这是一个用于投资组合分析的技能,支持从免费API获取各类资产行情数据,并提供文字报告和图表可视化。优化版本整合了滚动窗口调仓逻辑和回测功能。

功能特性

✅ 投资组合分析(资产配置、风险评估、收益分析) ✅ 支持多种资产类型:股票、ETF、加密货币等 ✅ 免费数据源集成 ✅ 文字报告生成 ✅ 图表可视化(收益曲线、资产分布、风险指标等) ✅ 滚动窗口风险平价分析(使用历史一年数据,每月调仓) ✅ 避免未来数据(使用expanding窗口计算波动率) ✅ 回测功能(完整的回测流程)

数据源

Yahoo Finance (通过yfinance库) Alpha Vantage (免费API) Finnhub (免费层) CSV文件(中国市场数据)

安装依赖

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密钥(如使用Alpha Vantage): ALPHA_VANTAGE_API_KEY=your_key_here

示例输出

中国市场滚动风险平价组合分析报告 ============================================================ 生成时间: 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/波动率) 每月调仓,动态调整权重 使用前一天的权重计算当日收益率

回测验证

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

注意事项

确保数据质量,处理缺失值和异常值 滚动窗口大小可根据实际情况调整 调仓频率可根据市场情况调整 考虑交易成本对回测结果的影响

Category context

Data access, storage, extraction, analysis, reporting, and insight generation.

Source: Tencent SkillHub

Largest current source with strong distribution and engagement signals.

Package contents

Included in package
3 Docs2 Scripts1 Config
  • SKILL.md Primary doc
  • README.md Docs
  • 优化使用指南.md Docs
  • optimized_main.py Scripts
  • optimized_risk_parity_skill.py Scripts
  • manifest.json Config