← story.propek
STORY MI-2.1
MI-2.1
Epic: Market Intel Macro v1
PENDING
ACCEPTANCE CRITERIA (11/11)
1. Script `scripts/fetch-commodity-prices.js` fetches 5 commodities from Alpha Vantage using config from `config/commodities.json`
2. Reads API key from `ALPHA_VANTAGE_KEY` environment variable -- never hardcoded, never logged
3. If API key is missing, prints clear setup instructions and exits with code 2 (FR-29)
4. Uses rate limiter at 5 req/min (0.083 req/sec) via `createLimiter(0.083)` to respect free tier
5. Handles Alpha Vantage rate limit response (JSON with `"Note"` key): wait 60s and retry once
6. Handles Alpha Vantage error response (JSON with `"Error Message"` key): log and skip commodity
7. Output `data/state/commodities-latest.json` with all commodity values, timestamps, and errors
8. Output appends to `data/timeseries/commodities.json` via `appendToSeries()`
9. Supports `--dry-run`, `--verbose`, `--help` flags
10. Each commodity fetched independently -- one failure does not block others
11. Exit code 0 on partial success, 1 on all failures, 2 on config error