The problem with manual stop-loss monitoring: you check your phone, the market moves while you're not watching, and you exit a position three points below where you meant to.
Here's how I built an automated stop-loss monitor that sends a Telegram alert within 2 seconds of a threshold breach — using Claude Code, Yahoo Finance's free API, and a SKILL.md file.
No broker API. No paid data service. No authentication flow.
How it works
The skill polls Yahoo Finance's undocumented quote endpoint every 5 minutes during market hours:
https://query1.finance.yahoo.com/v8/finance/chart/{ticker}?range=1d&interval=1m
When the current price crosses a configured threshold, it fires a Telegram alert and logs to a 30-minute deduplication cache (so you don't get spammed if a stock bounces around a level).
Market hours detection
No point running the monitor at 3am or on weekends. The skill checks market session before each poll:
Pre-market: 04:00 — 09:30 ET (alerts enabled, wider thresholds)
Regular: 09:30 — 16:00 ET (alerts enabled, normal thresholds)
After-hours: 16:00 — 20:00 ET (alerts enabled, wider thresholds)
Closed: all other times (skip)
Weekend detection prevents the monitor from running at all on Saturday/Sunday.
The Telegram alert format
[ALERT] TEM — Stop-loss triggered
Price: $47.13 | Threshold: $47.50
Session: Regular hours | Time: 14:23 ET
Distance from threshold: -0.78%
Action: Review position sizing. Exit if conviction unchanged.
This format is intentional: price, threshold, distance from threshold, and a suggested action in one message. No dashboard to open.
Configuration
The skill accepts natural language configuration in Claude Code:
Monitor these positions:
- AAPL: stop-loss $170, take-profit $200
- NVDA: stop-loss $110
- TEM: stop-loss $47.50, take-profit $55
- IREN: stop-loss $50
Alert me via Telegram when any threshold is hit.
Check every 5 minutes during market hours.
Claude parses this into a position config object and starts the monitoring loop.
What it caught in production
Two live examples from running this on a real portfolio:
TEM at $47.44 — stop-loss set at $47.50. Alert fired 4 minutes after the open. Exited before the next leg down to $44.
IREN at $50 support — set an alert at $50 exactly. Alert fired at $49.97 during after-hours. Position size reduced ahead of open.
Neither of these required me to watch a chart. The alert came to my phone, I checked the news, made a decision.
Deduplication logic
Without deduplication, a stock bouncing around your stop-loss level sends an alert every 5 minutes. The 30-minute cache solves this:
First breach: alert fires, timestamp logged
Next poll (5 min later): price still below threshold → skip (within 30-min window)
35 minutes later: if price recovered and then drops again → alert fires again
The cache resets if price recovers above threshold and then breaches again — so you're not silenced on a genuine second breach.
Installation
The free version monitors up to 3 tickers. It's in the open-source repo:
# Clone and install the free skill
git clone https://github.com/tellmefrankie/ai-investment-skills
cp price-monitor-alert/SKILL.md ~/.claude/skills/price-monitor-alert.md
Then in Claude Code:
/price-monitor-alert
Monitor AAPL stop-loss $170, NVDA stop-loss $110
Alert me via Telegram
The full version (unlimited tickers + options flow alerts) is in the Pro Bundle ($29).
Why Yahoo Finance instead of a paid API
Yahoo Finance's quote endpoint has been publicly accessible for years. It's not documented, not guaranteed, but it works. For a personal portfolio monitor, the latency (under 1 second) and 5-minute polling interval are both fine.
If you need tick-level data or guaranteed uptime, Polygon.io Basic ($29/month) is the right tool. The Options Flow Analyzer in the same repo uses Polygon for that reason.
The repo is MIT licensed: github.com/tellmefrankie/ai-investment-skills
Not financial advice. Monitor your own positions responsibly.
Top comments (0)