sector-compare
Automates financial comparison of industry peers using YFinance data.
Install
mkdir -p .claude/skills/sector-compare && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15918" && unzip -o skill.zip -d .claude/skills/sector-compare && rm skill.zipInstalls to .claude/skills/sector-compare
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Compare stocks within the same sector or industry. Use when: comparing multiple tickers, sector comparison, industry peer analysis, which stock is cheaper, forward PE comparison, earnings date, gross margin, moat comparison, 比較同產業, 哪支比較便宜, 產業比較, 同類股比較.Key capabilities
- →Compare multiple stock tickers
- →Analyze industry peer groups
- →Determine cheaper stocks by Forward PE
- →Check earnings dates for stocks
- →Compare gross margins
How it works
The skill fetches financial data using yfinance, calculates metrics like Forward PE and gross margin, and presents a comparison table with an evaluation.
Inputs & outputs
When to use sector-compare
- →Compare stock tickers
- →Check sector PE
- →Analyze industry gross margins
- →Find cheaper stocks
About this skill
Sector Comparison Skill
When to Use
- 比較同產業多支股票
- 想知道哪支 Forward PE 最低(最便宜)
- 查詢各股財報日期
- 比較毛利率、護城河強度
- 決定相同產業中要買哪支
Procedure
Step 1:用 yfinance 抓取基本數據(含財報日 + 法說日)
import yfinance as yf
from datetime import datetime, date
tickers = ["AVGO", "MRVL", "CRDO"] # 替換成要比較的標的
def fmt_date(d):
if d is None:
return "N/A"
if isinstance(d, (int, float)):
return datetime.fromtimestamp(d).strftime("%Y-%m-%d")
if isinstance(d, (datetime, date)):
return str(d)[:10]
return str(d)[:10]
results = []
for t in tickers:
stock = yf.Ticker(t)
info = stock.info
cal = stock.calendar or {}
# 財報日(優先從 calendar 取,再 fallback info)
earnings_dates = cal.get("Earnings Date", [])
earnings_date = earnings_dates[0] if earnings_dates else (
info.get("earningsDate") or info.get("earningsTimestamp")
)
# 美股財報日 = 法說日;台股需手動查 MOPS
investor_day = fmt_date(earnings_dates[0]) + " (法說/財報)" if earnings_dates else "查 IR 頁面"
results.append({
"ticker": t,
"price": info.get("currentPrice") or info.get("regularMarketPrice"),
"forward_pe": info.get("forwardPE"),
"trailing_pe": info.get("trailingPE"),
"gross_margin": round(info.get("grossMargins", 0) * 100, 1),
"market_cap_b": round(info.get("marketCap", 0) / 1e9, 1),
"earnings_date": fmt_date(earnings_date),
"investor_day": investor_day,
})
# 排序:Forward PE 由低到高
results.sort(key=lambda x: (x["forward_pe"] or 9999))
print(f"{'Ticker':<8} {'Price':>8} {'Fwd PE':>8} {'Trl PE':>8} {'GrossM':>8} {'MktCap(B)':>10} {'財報日':<14} {'法說日'}")
print("-" * 95)
for r in results:
print(f"{r['ticker']:<8} {str(r['price'] or 'N/A'):>8} {str(r['forward_pe'] or 'N/A'):>8} "
f"{str(r['trailing_pe'] or 'N/A'):>8} {str(r['gross_margin']) + '%':>8} "
f"{str(r['market_cap_b']) + 'B':>10} {r['earnings_date']:<14} {r['investor_day']}")
注意:
- 美股:財報日 = 法說日(同一天召開),直接從
yf.Ticker.calendar取得- 台股:yfinance 通常無財報日,需查 公開資訊觀測站 或 Goodinfo
- 法說日若 yfinance 無資料,需至該公司 IR 頁面確認
Step 2:輸出比較表
格式如下(財報日與法說日為必填欄位,若在 7 天內須用 🔴 標示):
| Ticker | 現價 | Forward PE | Trailing PE | 毛利率 | 市值 | 財報日 | 法說日 | 貴不貴 |
|---|---|---|---|---|---|---|---|---|
| AVGO | ... | 23.3x | 82.6x | 76.7% | ... | 2026-06-04 | 2026-06-04 | ✅ 合理 |
| MRVL | ... | 30.3x | 53.5x | 51.0% | ... | 🔴 2026-05-29 | 🔴 2026-05-29 | ✅ 合理 |
| CRDO | ... | 35.8x | 107.8x | 67.8% | ... | 2026-06-02 | 2026-06-02 | 🟡 偏貴 |
⚠️ 財報日/法說日在 7 天內 → 必須用 🔴 標示,並在結論中提醒短期波動風險 ⚠️ 台股若 yfinance 抓不到日期 → 明確標注「需查 MOPS」,不可留空或略過
Step 3:評估「貴不貴」
用 Forward PE 判斷:
| Forward PE | 評估 |
|---|---|
| < 25x | ✅ 合理 |
| 25x ~ 40x | 🟡 偏貴但看成長性 |
| 40x ~ 60x | 🔴 貴,需高成長支撐 |
| > 60x | 🔴🔴 非常貴 |
同時考量:
- 毛利率 > 60% = 高品質護城河
- 財報日 即將到來 = 短期波動風險提高
Step 4:給出結論
推薦順序:Forward PE 最低 + 毛利率最高 = 最甜蜜點
避開:毛利率低 + PE 貴 + 護城河弱
快速參考:常見護城河評分
| 護城河強度 | 特徵 |
|---|---|
| ★★★★★ | 壟斷性技術/平台,客戶鎖定期長 |
| ★★★★ | 雙頭壟斷,替換成本高 |
| ★★★ | 技術壁壘存在但有競爭者 |
| ★★ | 差異化不明顯,定價能力弱 |
| ★ | 純商品化,價格競爭 |
When not to use it
- →When comparing stocks across different sectors
- →When detailed fundamental analysis beyond provided metrics is required
Prerequisites
Limitations
- →Relies on yfinance for data, which may not have all data for all stocks (e.g., Taiwan stocks earnings dates)
- →Evaluation of 'expensive or cheap' is based on predefined Forward PE ranges
- →Moat comparison is based on common characteristics, not a quantitative model
How it compares
This skill automates the process of fetching and comparing specific financial metrics for stocks within a sector, unlike manual data collection and analysis.
Compared to similar skills
sector-compare side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| sector-compare (this skill) | 0 | 3mo | No flags | Intermediate |
| quant-analyst | 103 | 3mo | No flags | Advanced |
| stock-analyzer | 71 | 2mo | Review | Beginner |
| pair-trade-screener | 11 | 1mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
quant-analyst
zenobi-us
Expert quantitative analyst specializing in financial modeling, algorithmic trading, and risk analytics. Masters statistical methods, derivatives pricing, and high-frequency trading with focus on mathematical rigor, performance optimization, and profitable strategy development.
stock-analyzer
FrancyJGLisboa
Provides comprehensive technical analysis for stocks and ETFs using RSI, MACD, Bollinger Bands, and other indicators. Activates when user requests stock analysis, technical indicators, trading signals, or market data for specific ticker symbols.
pair-trade-screener
tradermonty
Statistical arbitrage tool for identifying and analyzing pair trading opportunities. Detects cointegrated stock pairs within sectors, analyzes spread behavior, calculates z-scores, and provides entry/exit recommendations for market-neutral strategies. Use when user requests pair trading opportunities, statistical arbitrage screening, mean-reversion strategies, or market-neutral portfolio construction. Supports correlation analysis, cointegration testing, and spread backtesting.
risk-metrics-calculation
wshobson
Calculate portfolio risk metrics including VaR, CVaR, Sharpe, Sortino, and drawdown analysis. Use when measuring portfolio risk, implementing risk limits, or building risk monitoring systems.
backtesting-trading-strategies
jeremylongshore
Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".
model-usage
openclaw
Use CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.