Stocks Portfolio Watch
Iterates over a portfolio of stock tickers and fires a per-ticker alert when any drops more than 5% intraday.
What it does
On each fire, the monitor uses the for_each: block to loop over a literal
list of tickers. Per ticker:
- The check fires (
stock-pricetool withsymbols: {{ticker}}). - The
when:arms evaluate against THAT ticker's outputs. - If today's change is ≤ -5%, fire a notify; otherwise the
else:arm matches.
So a 4-ticker portfolio + one bad mover produces one notification (not four,
not zero). The loop variable {{ticker}} is interpolated both into the check
args AND into the condition / notify body — same value in scope across all
three.
Edit before installing
In monitor.yaml:
for_each.items— replace with your portfolio: any list of Yahoo Finance symbols.for_each.as— the loop variable name. Defaultticker; if you change it, update every{{ticker}}reference downstream.when[0].condition— change the threshold.-5is a sharp move; for less volatile holdings use-3or-2.- For a percentage-up alert as well, add another arm:
{{check.prices.{{ticker}}.changePercent}} >= 5
Bindings used per iteration
{{ticker}}— current loop value (literal string from theitems:list).{{check.prices.<TICKER>.price}}— current price for THIS ticker.{{check.prices.<TICKER>.changePercent}}— today's percent change.{{check.summary}}— formatted summary line (covers only this ticker sincesymbols:was scoped to one symbol).
Tool used
stock-price — hub-installed YAML tool, queries
Yahoo Finance. No API key required.
Pattern showcase
This is the literal for_each iteration pattern. The portfolio lives in
the monitor's YAML, so to edit your watchlist you edit the file.
The alternative for_each.source: form (covered by the news-sentiment-check
monitor) pulls the iteration list dynamically from a tool — useful when the
"what to watch" list itself changes (e.g. a holdings query, an unresolved-
incidents list).
Watch-out
Per-fire token usage: a 10-ticker portfolio = 10 separate stock-price tool
calls each fire. For large portfolios, either lower the schedule cadence
(daily instead of hourly) or pass all tickers in one call via the single-arm
stock-price-watch monitor with symbols: AAPL,MSFT,NVDA,... and reference
each price directly in the condition.