get_etf_holdings
List the constituents of an ETF.
Base mode (default): returns every holding with its weight % in the
index — {ticker, name, weight_pct}.
Top-performers mode: pass `sort_by` (one of '5d', 'month', 'ytd',
'year') and a `limit` > 0 to get the top N constituents by that
period's return. Each row carries weight_pct, current_price,
return_pct for the chosen period, and analyst_consensus.
Use the top-performers mode for questions like 'which stocks in XLK
rose most this week' without separately calling a screener.
Args:
ticker: ETF ticker (e.g. 'SPY', 'QQQ').
sort_by: '' for full list, or one of '5d', 'month', 'ytd', 'year'.
limit: 0 to return all constituents; >0 (max 50) to return top N. A
negative or non-numeric limit is REJECTED rather than treated as 0 —
`limit` picks the mode here, so defaulting an unusable one would
answer a ranked top-N request with the full unranked list.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| ticker | Yes | ||
| sort_by | No | Optional prices field to sort by descending (e.g. 'prices.5d.gain', 'prices.twoWeeks.gain', 'prices.month.gain'); when set, returns top performers instead of the full list. |