Agentara stock
git clone https://github.com/MagicCube/agentara
T=$(mktemp -d) && git clone --depth=1 https://github.com/MagicCube/agentara "$T" && mkdir -p ~/.claude/skills && cp -r "$T/user-home/.claude/skills/stock" ~/.claude/skills/magiccube-agentara-stock && rm -rf "$T"
user-home/.claude/skills/stock/SKILL.mdStock Quote Skill
Fetch latest stock price, change, and anomaly detection for US stocks, HK stocks, and A-shares. Uses stooq.com as data source — reliable, no auth, bypasses system proxy automatically. Data is T+1 for all markets (previous trading day close). This is expected and normal.
Step 1 — Identify Stock & Market
Parse the user's query:
- A-share: 6-digit code (000001, 600519, 300750) or Chinese company name → market =
cn - HK stock: 4–5 digit code (9988, 00700, 9999) or
format → market =XXXX.HKhk - US stock: Latin ticker (BABA, AAPL, TSLA, NVDA) or
format → market =BABA.USus
For well-known companies, infer the market:
- 阿里巴巴 → BABA (US) + 09988 (HK) — user usually means one, ask if unclear
- 腾讯 → 00700 (HK)
- 茅台/贵州茅台 → 600519 (A-share)
- 宁德时代 → 300750 (A-share)
For HK symbols, pass as-is (no zero-padding):
9988, 700. stooq handles it.
Step 2 — Fetch Data
Use the unified
fetch_stock.py script. Market codes: hk, cn, us.
# HK stock python3 /Users/henry/.agentara/.claude/skills/stock/fetch_stock.py hk 9988 # A-share python3 /Users/henry/.agentara/.claude/skills/stock/fetch_stock.py cn 600519 # US stock python3 /Users/henry/.agentara/.claude/skills/stock/fetch_stock.py us BABA
Output is a JSON array of rows:
{date, open, close, high, low, vol, pct, chg}.
If the output starts with {"error":, report the error to the user and stop.
Network notes: stooq.com is called with
trust_env=False (bypasses Clash/system proxy).
No external Python deps beyond requests (stdlib-equivalent, always available).
Stooq symbol format:
- HK:
(no leading zeros)9988.hk - CN:
600519.cn - US:
(lowercase)baba.us
Step 3 — Analyze & Detect Anomalies
From the JSON output (up to 21 rows):
- Latest row = most recent trading day data
- Latest price =
of last rowclose - Latest change% =
of last rowpct - Avg volatility = mean of
of rows 2–21 (excluding last row)|pct| - Avg volume = mean of
of rows 2–6 (5-day avg, excluding last)vol - Latest volume =
of last rowvol
Anomaly flags (report any that apply):
→ 🚨 大幅波动|pct| > 5%
AND|pct| > 2%
→ ⚠️ 异常波动(超出近期均值2倍)|pct| > 2 × avg_volatility
→ 📊 成交量异常放大(X倍)latest_vol > 2 × avg_volume
→ 🔇 成交量异常萎缩latest_vol < 0.4 × avg_volume
If US stock
pct is always near 0 except the last row, it's because the diff is computed on fetched data — use the last row's pct directly.
Step 4 — Format Output
Keep it brief and mobile-friendly. Use list format, no tables.
Color + emoji rules (Chinese convention: 红涨绿跌):
→ emoji 📈, wrap numbers inpct > 0<font color='red'>...</font>
→ emoji 📉, wrap numbers inpct < 0<font color='green'>...</font>
→ emoji ➡️, no color wrapperpct == 0
Template (adapt to context):
**{公司名} · {市场} {代码}** - 最新价:<font color='red/green'>**{price} {货币}**</font> - 涨跌:{emoji} <font color='red/green'>**{chg:+.2f} / {pct:+.2f}%**</font> - 最新交易日:{date} {anomaly_section_if_any}
Anomaly section (only if flags exist):
⚠️ 异常提示 - [flag 1] - [flag 2] 近5日均幅 **{avg_vol:.2f}%**,今日 <font color='red/green'>**{pct:.2f}%**</font>
If no anomaly: omit the anomaly section entirely. Keep the whole response under 10 lines.
Step 5 — Currency
- A-share: ¥ (人民币)
- HK: HK$ (港元)
- US: $ (美元)
Notes
- US data lags by 1 trading day (Sina source) — this is expected, tell the user if they ask
- If AKShare is not installed:
pip3 install akshare -q - If the symbol is wrong or not found, tell the user and suggest the correct format
- For A-share names, you can infer the 6-digit code from common knowledge; if uncertain, say so
- Do NOT show raw JSON or DataFrame output to the user — always parse and format it