首页龙虾技能列表 › StockBuddy — 技能工具

StockBuddy — 技能工具

v1.0.8

Multi-market stock analysis and portfolio execution assistant for CN, HK, and US equities. Provides technical + basic valuation analysis, portfolio review, a...

1· 144·0 当前·0 累计
by @tacitlab (Tacit Lab)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/6
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
medium confidence
StockBuddy's code, runtime instructions, and requested resources are broadly consistent with a multi-market stock analysis and portfolio management tool, with a few implementation vs documentation mismatches you should be aware of before installing.
评估建议
What to consider before installing: 1) Persistence: the tool stores portfolio, watchlist, K-line and cached analysis in ~/.stockbuddy/stockbuddy.db — review and backup or run it in an isolated environment if you don't want persistent files in your home directory. 2) Network access: the scripts fetch data from public finance endpoints (Tencent, EastMoney, Yahoo, SEC). If you require offline or audited endpoints, inspect the data-fetch code before use. 3) Dependency installation: install_deps.sh m...
详细分析 ▾
用途与能力
Name/description (multi-market analysis + portfolio execution) matches the included scripts: analyze_stock.py (data fetch + analysis), portfolio_manager.py (positions/accounts/rules), and db.py (SQLite persistence). The declared data sources (Tencent, Yahoo, EastMoney, SEC) align with code network calls.
指令范围
SKILL.md instructs running the bundled scripts and to persist durable facts while computing live metrics at runtime. The code implements caching and stores watchlist/portfolio/kline data in ~/.stockbuddy/stockbuddy.db (including a last_price column). The README rule 'Do not write latest price, position weight, or unrealized P&L back into durable storage' appears in tension with code paths (portfolio_manager.ensure_watch_item / upsert_watchlist_item) that populate last_price/quote_time. This is an implementation vs documentation inconsistency rather than clear malicious behavior, but it affects expectations about what data is persisted.
安装机制
There is no package manager install spec (lowest risk), but a bundled install_deps.sh will attempt pip3 installs (including --break-system-packages and --user fallbacks). Running that script will modify the Python environment if invoked; it's optional per SKILL.md (only run if dependencies missing) but you should review/execute it in a controlled environment (virtualenv/container) to avoid altering system Python packages.
凭证需求
The skill does not request environment variables, external credentials, or secrets. All external interactions are with public finance data providers described in the docs. No unrelated service keys or system credentials are requested.
持久化与权限
The skill persists data to an on-disk SQLite DB at ~/.stockbuddy/stockbuddy.db (watchlist, positions, kline, caches). This is expected for a portfolio tool but is persistent on the user's home directory. always is false and the skill does not request elevated OS privileges. If you prefer not to persist data globally, run in an isolated user or containerized environment or review/modify DB_PATH in db.py.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.82026/3/31

Improve execution-aware guidance, position intake follow-ups, and cash-aware buy suggestions.

● 无害

安装命令 点击复制

官方npx clawhub@latest install stockbuddy
镜像加速npx clawhub@latest install stockbuddy --registry https://cn.clawhub-mirror.com

技能文档

Overview

StockBuddy is a stock analysis and portfolio execution support skill for A-share, Hong Kong, and US equities. It outputs quantified scores and clear action labels (Strong Buy / Buy / Hold / Sell / Strong Sell). By default, responses are decision-first: give the concise conclusion, score/confidence, event-adjusted second-pass suggestion, and practical order ideas before expanding into a long-form report.

Core rule: separate durable facts from derived values.

  • Persist durable facts: share count, cost basis, account, available cash, market/currency, lot size, odd-lot support, and other user-confirmed trading constraints
  • Compute in real time: latest price, market value, position weight, unrealized P&L, executable buy/sell size, and whether partial selling is actually possible
  • Do not write latest price, position weight, or unrealized P&L back into durable storage

Five core scenarios:

  • Single-stock analysis — analyze one stock and produce an action recommendation
  • Batch portfolio analysis — analyze current positions and summarize stock-level and portfolio-level status
  • Position management — add, update, remove, and inspect positions
  • Account and allocation management — track account, cash, market/currency, and execution constraints
  • Watchlist management — add, remove, and inspect watched stocks while storing basic stock metadata and trading rules

Execution-Aware Advice Rules

Before giving execution-ready trading advice, confirm whether the durable constraints are sufficient.

Required durable facts for execution-aware advice:

  • account context
  • market / currency
  • available cash for the account
  • lot size
  • odd-lot support when relevant

If these are incomplete:

  • still give a directional view when possible
  • label it as directional only or non-execution-ready
  • ask only for the missing durable facts
  • do not invent quantity, allocation, or partial-sell actions that may be impossible in the real market setup

Special rule for buy advice:

  • If available cash is unknown, do not provide quantity, allocation, or order-size advice.
  • Ask for the account plus available cash first.

Special rule for sell/trim advice:

  • If lot size or odd-lot support is unknown, avoid suggesting partial sells as if they are definitely executable.
  • If the user holds only one lot and odd-lot selling is not supported, suggest only executable actions such as hold or sell the full lot.

Environment Setup

Only install dependencies when they are actually missing, or when a script fails with a missing-package error:

bash {{SKILL_DIR}}/scripts/install_deps.sh

Required dependencies: numpy, pandas, built-in Python sqlite3. No yfinance dependency is required; the current implementation mainly uses Tencent Finance data.

Core Workflow

Scenario 1: Analyze a Single Stock

Trigger examples: "analyze Tencent", "can I buy this stock", "look at BYD", "analyze this ticker"

Steps:

  • Normalize the stock code
- Hong Kong stocks: normalize to XXXX.HK - A-shares: normalize to SH600519 / SZ000001 - US stocks: normalize to AAPL / TSLA - If the user provides only a company name, infer the market from context first; ask for confirmation only if the mapping is ambiguous

  • Run the analysis script
   python3 {{SKILL_DIR}}/scripts/analyze_stock.py  --period 6mo
   
Optional period values: 1mo / 3mo / 6mo (default) / 1y / 2y / 5y

Data and caching behavior: - Raw daily K-line data, watchlist data, and portfolio data are stored in ~/.stockbuddy/stockbuddy.db (SQLite) - Positions are linked through watchlist_id - Analysis results are cached separately in SQLite with a default TTL of 10 minutes - Cache cleanup runs automatically and total cached analysis rows are capped - If the user explicitly asks to "refresh data" or "reanalyze", add --no-cache - To clear analysis cache: --clear-cache

  • Interpret and present the result
- The script returns JSON analysis data - For default single-stock requests, use the default query template in references/output_templates.md - The default response must include: stock basics, data-driven action recommendation (with score and confidence), important events, event-adjusted second-pass suggestion, and practical order ideas - Default order style = balanced. Only switch when the user explicitly asks for a conservative or aggressive version - Only produce the full report when explicitly requested with phrases like "full report", "detailed analysis", or "complete analysis" - The top natural-language summary is mandatory in both short and long versions: 2-4 sentences covering regime, main recommendation, confidence, support/risk points, and whether the stock is actionable today - Only expand into a more open-ended explanation when the user asks for detail such as "explain why", "show the reasoning", "how about short-term", or "what stop-loss/stop-profit should I use" - Final output must be normal Markdown, not wrapped in code fences; prefer short paragraphs, bullet points, and card-style formatting over wide tables unless the user explicitly wants a detailed report

Scenario 2: Batch Portfolio Analysis

Trigger examples: "analyze my portfolio", "look at my holdings", "how are my positions doing"

Default output should still be decision-first: for each position, give the action label, score/confidence, important events, event-adjusted second suggestion, and a compact practical order version. Do not expand every holding into a full long report unless the user explicitly wants a detailed version.

Steps:

  • Check portfolio data
   python3 {{SKILL_DIR}}/scripts/portfolio_manager.py list
   
Portfolio data is stored in the positions table in ~/.stockbuddy/stockbuddy.db.

  • If the portfolio is empty → guide the user to add positions first (see Scenario 3)
  • Run batch analysis
   python3 {{SKILL_DIR}}/scripts/portfolio_manager.py analyze
   
  • Interpret and present the result
- Format the result using the "Portfolio Batch Analysis Report" section in references/output_templates.md - Output normal Markdown, not code fences - It may use standard Markdown tables mixed with lists when helpful, but keep it readable on chat surfaces - Include stock-level recommendations and portfolio-level P&L summary - Prefer real-time computed fields in the output: latest price, market value, unrealized P&L, position weight, and executable action constraints such as whole-lot vs odd-lot behavior - Do not write latest price, position weight, or unrealized P&L back into durable storage; the database should only hold stable user-confirmed facts and trading rules

Scenario 3: Position Management

Trigger examples: "add a Tencent position", "I bought 100 shares of BYD", "remove Alibaba from my holdings"

ActionCommand
Add positionpython3 {{SKILL_DIR}}/scripts/portfolio_manager.py add --price --shares [--date ] [--note ] [--account ]
List positionspython3 {{SKILL_DIR}}/scripts/portfolio_manager.py list
Update positionpython3 {{SKILL_DIR}}/scripts/portfolio_manager.py update [--price ] [--shares ] [--note ] [--account ]
Remove positionpython3 {{SKILL_DIR}}/scripts/portfolio_manager.py remove
List accountspython3 {{SKILL_DIR}}/scripts/portfolio_manager.py account-list
Create/update accountpython3 {{SKILL_DIR}}/scripts/portfolio_manager.py account-upsert [--market ] [--currency ] [--cash ] [--available-cash ] [--note ]
Set trading rulepython3 {{SKILL_DIR}}/scripts/portfolio_manager.py rule-set [--lot-size ] [--tick-size ] [--odd-lot]
When adding a position, ensure the stock exists in the watchlist and is linked through positions.watchlist_id -> watchlist.id. If the user does not provide a date, default to the current date. If the user provides natural-language trade info such as "I bought 100 shares of Tencent last week at 350", extract price, share count, date, and account info where possible, then execute the appropriate command.

After the first successful position record, proactively guide the user to fill the missing durable facts needed for execution-aware advice. Do not stop at only code / shares / cost if important constraints are still unknown.

Ask for or help the user confirm these fields, in this priority order:

  • Account context — which account this belongs to, and its market / currency
  • Cash — total cash or available cash in that account
  • Lot rule — lot size for the stock
  • Odd-lot support — whether the broker supports odd-lot selling / buying
  • Trade date — if omitted and relevant for later review
  • Notes — optional thesis, time horizon, or special constraints

If some fields are already known, only ask for the missing ones. Keep the follow-up compact: confirm what was captured, state what is still missing, and ask for the missing durable facts in one short message.

If the user gives only partial follow-up info, update what is available and continue asking only for the remaining missing fields. Once enough execution constraints are known, stop prompting and proceed normally.

Scenario 4: Account and Allocation Management

Trigger examples: "my HK account has 3000 HKD cash", "track available cash", "record this under my US account", "how concentrated is my portfolio"

Rules:

  • Keep cash, account, market, and currency as durable facts
  • Keep position weights, market value, and unrealized P&L as computed fields
  • If the user has multiple markets or currencies, treat them as separate account contexts unless the user explicitly wants cross-account aggregation
  • Use account information to improve practical trading advice: whether the user can afford a new lot, whether a rebalance is even possible, and whether the trade would increase concentration too much

Scenario 5: Watchlist Management

Trigger examples: "watch Tencent", "add Apple to my watchlist", "remove Moutai from watchlist"

ActionCommand
List watchlistpython3 {{SKILL_DIR}}/scripts/portfolio_manager.py watch-list
Add watch itempython3 {{SKILL_DIR}}/scripts/portfolio_manager.py watch-add
Remove watch itempython3 {{SKILL_DIR}}/scripts/portfolio_manager.py watch-remove

Analysis Methodology

The scoring system combines technicals (roughly 60% weight) and basic valuation (roughly 40% weight). Final score range is approximately -10 to +10:

Score RangeRecommendation
≥ 5🟢🟢 Strong Buy
2 ~ 4🟢 Buy
-1 ~ 1🟡 Hold / Watch
-4 ~ -2🔴 Sell
≤ -5🔴🔴 Strong Sell
Only read references/technical_indicators.md when the user asks for detailed scoring logic, indicator interpretation, or when you need help calibrating a more detailed explanation.

When deciding the final output format, choosing between default query vs full report, or generating practical order suggestions, prefer references/output_templates.md. It defines the default query template, atomic templates, full-report composition rules, and the conservative / balanced / aggressive order-price generation rules (balanced is the default).

Important Notes

  • All analysis is for reference only and is not investment advice
  • The primary data source is Tencent Finance, which may have delays, gaps, or field limitations
  • Hong Kong stocks do not have the same daily price-limit structure as A-shares and therefore carry higher intraday volatility risk
  • Every final analysis output must include a risk disclaimer
  • Technical analysis can fail during extreme market conditions
  • Encourage the user to combine macro conditions, sector trends, and company fundamentals in final decision-making
  • Only store user-confirmed durable facts in the database; latest price, market value, unrealized P&L, and position weight should be fetched or calculated at analysis time

Resource Files

FilePurpose
scripts/analyze_stock.pyCore analysis script for market data retrieval, technical indicators, and valuation scoring
scripts/portfolio_manager.pyPortfolio/account/watchlist management and batch analysis entry point
scripts/install_deps.shDependency installation script
references/technical_indicators.mdDetailed technical indicator and scoring reference
references/output_templates.mdOutput template controller: default query template, atomic templates, full-report rules, and practical order generation rules
references/data-source-roadmap.mdData-source roadmap for primary/fallback/event-layer evolution; read only when extending data sources or event coverage
数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务