Skill flagged — suspicious patterns detected

ClawHub Security flagged this skill as suspicious. Review the scan results before using.

Temp Skill

v1.0.0

提供基于免费数据源的多资产投资组合分析,支持滚动窗口风险平价调仓及完整回测和图表报告生成。

0· 397·3 current·3 all-time
Security Scan
VirusTotalVirusTotal
Suspicious
View report →
OpenClawOpenClaw
Suspicious
medium confidence
!
Purpose & Capability
The SKILL.md and README claim integration with Yahoo Finance (yfinance), Alpha Vantage, and Finnhub and instruct setting ALPHA_VANTAGE_API_KEY, but the provided Python code focuses on loading local CSV files and contains no obvious network/API calls in the visible portions. The manifest dependencies also omit yfinance/plotly while SKILL.md's pip install list includes them. These discrepancies mean the declared capabilities (live API fetching) do not match the actual code and requirements.
Instruction Scope
Runtime instructions tell the agent/user to run scripts that operate on local CSVs and mention configuring an Alpha Vantage API key. The shipped scripts (optimized_main.py and optimized_risk_parity_skill.py) as shown read local CSV, compute metrics, and write reports/charts — they do not (in the visible code) request or transmit secrets. However the SKILL.md allows/mentions free API sources and an API key; that expands the expected scope but is not reflected in the code. Also the SKILL.md references a default path under C:\Users\... which may cause accidental use of a local file.
Install Mechanism
There is no automated install spec (instruction-only install). That minimizes supply-chain risk from downloads. The SKILL.md suggests pip installing typical data-science packages (pandas/numpy/matplotlib/seaborn/plotly/yfinance). Those are expected for this domain; no remote/executable download URLs are present in the package.
!
Credentials
The SKILL.md instructs setting ALPHA_VANTAGE_API_KEY but the skill metadata lists no required environment variables and the visible code does not reference any env var. This mismatch is a red flag: either the docs are outdated (harmless) or parts of the skill (not visible in truncated code) use credentials but do not declare them. Users should not supply API keys until confirming where/if they're used.
Persistence & Privilege
The skill does not request persistent or privileged presence (always is false). It appears to operate as a run-on-demand script that reads CSVs and writes reports/charts into the filesystem; no evidence of modifying other skills or agent configs was found in the visible files.
What to consider before installing
Do not run this skill blindly. Key concerns: (1) The documentation promises live API fetching and asks for an ALPHA_VANTAGE_API_KEY, but the included code shown works only with local CSVs — verify whether any hidden/remaining code does network calls before providing API keys. (2) The manifests/docs disagree about dependencies (yfinance/plotly appear in README/SKILL.md but not in manifest); install only the packages you need and inspect imports. (3) Review the full optimized_risk_parity_skill.py and optimized_main.py for any network, subprocess, or filesystem writes (the provided excerpt is truncated and contains an apparent unfinished return referencing an undefined variable). Run the code in a sandboxed environment with non-sensitive sample CSVs first, and consider static inspection or running with tracing to detect unexpected outbound connections. If you intend to use live APIs, only supply API keys after confirming exactly which module will use them and where keys are read from.

Like a lobster shell, security has layers — review code before you run it.

latestvk979j72dfqs1v4br98c5ccapt181xz5n
397downloads
0stars
1versions
Updated 8h ago
v1.0.0
MIT-0

金融分析技能 (Financial Analysis Skill)

概述

这是一个用于投资组合分析的技能,支持从免费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%
}

滚动窗口风险平价分析

核心特点

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

分析流程

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

输出文件

  • 分析报告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/波动率)
  • 每月调仓,动态调整权重
  • 使用前一天的权重计算当日收益率

回测验证

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

注意事项

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

Comments

Loading comments...