1.0 KiB
1.0 KiB
| type | status | date | agent_author | tags | related_files | ||||
|---|---|---|---|---|---|---|---|---|---|
| decision | active | 2026-03-17 | claude |
|
|
Context
yfinance.Sector("technology").overview returns only metadata (companies_count, market_cap, etc.) — no performance data (oneDay, oneWeek, etc.).
The Decision
Use SPDR sector ETFs as proxies:
sector_etfs = {
"Technology": "XLK", "Healthcare": "XLV", "Financials": "XLF",
"Energy": "XLE", "Consumer Discretionary": "XLY", ...
}
Download 6 months of history via yf.download() and compute 1-day, 1-week, 1-month, YTD percentage changes from closing prices.
Constraints
yfinance.Sector.overviewhas NO performance data — do not attempt to use it.top_companieshas ticker as INDEX, not column. Always use.iterrows().
Actionable Rules
- Always test yfinance APIs interactively before writing agent code.
- Always inspect DataFrame structure with
.head(),.columns, and.index.