Stock Portfolio

v1.0.0

股票组合管理与预警技能。支持 A 股/港股/美股行情查询、持仓跟踪、收益计算、价格预警、每日推荐。使用免费 API(腾讯财经),数据本地存储。

0· 207·1 current·1 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for yinshengf/stock-portfolio.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Stock Portfolio" (yinshengf/stock-portfolio) from ClawHub.
Skill page: https://clawhub.ai/yinshengf/stock-portfolio
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install stock-portfolio

ClawHub CLI

Package manager switcher

npx clawhub@latest install stock-portfolio
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
Name/description (portfolio management, alerts, daily picks) align with the files and runtime instructions. The only network activity is toward public finance APIs (Tencent, Sina, EastMoney, Yahoo) which is expected for this purpose. No environment variables, credentials, or unrelated binaries are requested.
Instruction Scope
SKILL.md directs the agent to run the included Python scripts and optionally set up cron jobs. The scripts operate on local JSON files under a workspace data directory and call public finance HTTP APIs — this matches the documented scope. Notes: cron examples use absolute /root paths and openclaw message send examples (these are just examples but could leak alert output to configured chat targets if misused). Also the free APIs used are HTTP and may be susceptible to MITM or modification in transit.
Install Mechanism
There is no install spec (instruction-only style) — code files are included and nothing is downloaded or installed automatically. This is the lower-risk pattern. You should still review and run code locally rather than allowing any automatic install.
Credentials
The skill requires no credentials or environment variables, and stores data locally in a skill-specific data directory. Requested access is proportionate to a portfolio/alert tool. There are no demands for unrelated secrets or system config paths.
Persistence & Privilege
always:false (not forced into every agent session). The skill stores only its own data under a local data directory and does not modify other skills or global agent config. Cron integration is optional and user-configured.
Assessment
This skill appears internally consistent for a local stock portfolio manager: it only calls public finance APIs and stores JSON files in its own data directory. Before installing/run: - Review the full code (you received some truncated file listings) to confirm there are no hidden network calls or unexpected behavior. Run it in a sandbox or VM first. - Note a code bug: data_sources.py (DataSourceManager) shows a likely typo/bug (assignment to undefined name 'source') — expect runtime errors; consider fixing or reviewing the module before use. - Cron examples assume /root paths and show piping output into openclaw message send; if you configure cron, ensure the target chat ID and message command are correct and trusted — otherwise alerts/reports could be sent to external recipients. - The skill uses unencrypted HTTP endpoints for some APIs (qt.gtimg.cn, hq.sinajs.cn, push2.eastmoney.com). That can be tampered with on insecure networks; consider switching to HTTPS-capable sources (Yahoo/official HTTPS endpoints) or run behind a trusted network. - Data privacy: holdings/alerts/history are stored locally under the skill workspace; back them up if important. The skill does not exfiltrate this data on its own, but any cron or notification configuration that sends data to third-party messaging channels will transmit it. If you want higher assurance, ask the author for a corrected/reviewed data_sources.py, or run a line-by-line audit and unit tests (especially network code) before making the skill autonomous.

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

latestvk970km38a9qm7d3736644jxj9d83fzkq
207downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

股票组合管理技能

核心功能

1. 📊 行情查询

  • 实时股价、涨跌幅、成交量
  • 支持 A 股(600xxx/000xxx/300xxx)、港股(00700)、美股(AAPL)

2. 💼 持仓管理

  • 记录买入价、持仓数量、加仓/减仓
  • 自动计算当前市值、盈亏金额、盈亏比例
  • 持仓数据本地存储(JSON 文件)

3. 🔔 价格预警

  • 设置目标价/涨跌幅阈值
  • 主动查询时检查预警状态
  • 可选 cron 定时监控

4. 💡 每日推荐

  • 每日 5 只股票推荐
  • 基于技术指标(涨跌幅、振幅、成交量)+ 基本面(行业龙头)
  • 多线程获取行情数据,快速响应
  • 推荐列表可配置(修改 STOCK_POOL)

快速开始

查询股价

# 使用脚本查询
python scripts/stock_fetch.py 600519
python scripts/stock_fetch.py AAPL

管理持仓

# 添加持仓
python scripts/portfolio_manager.py add --symbol 600519 --price 1500 --shares 100

# 查看持仓
python scripts/portfolio_manager.py list

# 计算收益
python scripts/portfolio_manager.py summary

设置预警

# 设置价格预警
python scripts/portfolio_manager.py alert --symbol 600519 --target 1600

# 查看预警
python scripts/portfolio_manager.py alerts

数据源

腾讯财经 API(免费、无需 key)

A 股格式: sh600519, sz000001, sz300750 港股格式: hk00700 美股格式: usAAPL, usTSLA

接口: http://qt.gtimg.cn/q={symbol}

返回示例:

v_sh600519="1~贵州茅台~600519~1408.81~1445.00~1433.33~..."

字段说明(~分隔):

  • 字段 0: 未知
  • 字段 1: 股票名称
  • 字段 2: 股票代码
  • 字段 3: 当前价格
  • 字段 4: 昨日收盘价
  • 字段 5: 今日开盘价
  • 字段 6: 成交量(手)
  • 字段 31: 涨跌额
  • 字段 32: 涨跌幅%
  • 字段 33: 今日最高价
  • 字段 34: 今日最低价
  • 字段 47: 成交额(万)

详细 API 文档见 references/api_docs.md

数据存储

持仓数据存储在:~/.openclaw/workspace/skills/stock-portfolio/data/

  • holdings.json - 持仓记录
  • alerts.json - 预警设置
  • history.json - 查询历史(可选)

每日推荐逻辑

推荐策略(见 references/recommendation_strategy.md):

  1. 技术面筛选(60% 权重)

    • 涨跌幅:温和上涨(0-3%)得分最高
    • 振幅:适度活跃(2-6%)得分高
    • 成交量:大于 500 万股加分
  2. 基本面筛选(40% 权重)

    • 行业龙头优先
    • 业绩稳定增长
    • 市值适中
  3. 随机因子

    • 基于日期种子,确保同一天推荐一致
    • 增加多样性,避免推荐过于集中

推荐结果每日更新,多线程获取行情数据(约 3-5 秒完成)。

使用示例

用户: "查询茅台今天的股价" 操作: 调用 stock_fetch.py sh600519,返回实时行情

用户: "我买了 100 股茅台,成本 1500" 操作: 调用 portfolio_manager.py add --symbol sh600519 --price 1500 --shares 100

用户: "我的持仓收益怎么样" 操作: 调用 portfolio_manager.py summary,获取当前股价并计算盈亏

用户: "茅台涨到 1600 提醒我" 操作: 调用 portfolio_manager.py alert --symbol sh600519 --target 1600

用户: "今天有什么股票推荐" 操作: 调用 scripts/daily_picks.py,返回 5 只推荐股票

定时任务(可选)

配置 cron 实现:

  • 每日 9:00 推送推荐股票
  • 每 30 分钟检查预警条件

references/cron_setup.md

注意事项

  1. 数据延迟:免费 API 有 15 分钟延迟(A 股实时,港股/美股延迟)
  2. 交易时间:非交易时间返回收盘价
  3. 复权处理:当前不支持复权,分红/拆股需手动调整成本
  4. 数据备份:定期备份 data/ 目录

扩展方向

  • 接入更多数据源(东方财富、Yahoo Finance)
  • 支持基金、债券
  • K 线图生成
  • 回测功能

Comments

Loading comments...