Skip to content

feat(metrics): swing metrics from the shared block - #108

Merged
daggerok merged 1 commit into
mainfrom
feat/swing-block
Nov 12, 2026
Merged

daggerok merged 1 commit into
mainfrom
feat/swing-block

Conversation

@daggerok

Copy link
Copy Markdown
Owner

What

  • Applies the shared swing block (.claude/tools/etfs/etf-std/swing.block.ts, apply-block.ts) in Yahoo mode: every metrics gets pctFrom52wHigh, athPrice, athDate, athBasis, pctFromAth, volatility1y, sigmaFromMean60d, high60d, low60d after the range52w keys, before returnsBasis and performanceAsOf
  • Wiring at the withRange52w call: withSwing(ROOT, await withRange52w(...), { fetchChart, tickers, previous, concurrency, onError })
    • fetchChart: iShares has no Yahoo helper, so the generic requestText (request gate lanes, retries with Retry-After, 120 s timeout). requestText gets an optional headers argument (default unchanged); the chart sends YAHOO_CHART_HEADERS with the browser User-Agent the other brands use for Yahoo (Bun's default UA is not a browser)
    • tickers: the funds whose fresh indexRow this run built (updated or unchanged, so not failed, filtered or kept); [] after the 25-minute soft deadline (deadlineHit), so the swing step never pushes a late run over the 30-minute job timeout (those funds keep their published swing keys). iShares has no SKIP_YAHOO control
    • previous: the previously published index rows (previousRows); onError prints a [ swing ] note
  • Tests: the one-ticker pipeline test asserts the swing key order (slice(-11, -2)), one swing chart request per refreshed fund (AAA, BBB, CCC) and the values (athBasis since 2025-01-02, athPrice 69.9, a number in volatility1y); the second one-ticker run still leaves every file unchanged; the mock answers the swing chart URL (period1=0) with 300 daily closes
  • README: swing list in ### Metrics and caveats

Why

Screener plan 1.6, item S5: the swing metrics of the Stocks feed in every ETF brand feed

Checks

  • swing-gates.sh <repo> baseline before the edit, swing-gates.sh <repo> check: all ok (bun test 42 pass 0 fail 350 expect() calls, test with the workflow controls, both builds, diff --check, check-readme, check-scripts, check-log-tags, apply-block --check, tc 53 lines = baseline 53)
  • Real run TICKERS=IVV ./scripts/update-data.ts (1 updated in 6.2 s): pctFrom52wHigh -2.28, athPrice 782.54, athDate 2026-10-06, athBasis daily closes since 2000-05-19, pctFromAth -2.28, volatility1y 13.73, sigmaFromMean60d -0.41, high60d 782.54, low60d 736.21; data discarded (git checkout -- api/)
  • Run time: recent scheduled runs take about 5 minutes for 482 funds (REQUEST_SLEEP 0, 4 lanes); 482 extra charts on 4 lanes fit well inside the 30-minute job

@daggerok
daggerok merged commit 84205a6 into main Nov 12, 2026
1 check passed
@daggerok
daggerok deleted the feat/swing-block branch November 12, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant