Repository navigation
feat(metrics): swing metrics from the shared block - #108
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
swingblock (.claude/tools/etfs/etf-std/swing.block.ts, apply-block.ts) in Yahoo mode: everymetricsgetspctFrom52wHigh,athPrice,athDate,athBasis,pctFromAth,volatility1y,sigmaFromMean60d,high60d,low60dafter the range52w keys, beforereturnsBasisandperformanceAsOfwithRange52wcall:withSwing(ROOT, await withRange52w(...), { fetchChart, tickers, previous, concurrency, onError })fetchChart: iShares has no Yahoo helper, so the genericrequestText(request gate lanes, retries with Retry-After, 120 s timeout).requestTextgets an optionalheadersargument (default unchanged); the chart sendsYAHOO_CHART_HEADERSwith the browser User-Agent the other brands use for Yahoo (Bun's default UA is not a browser)tickers: the funds whose freshindexRowthis run built (updatedorunchanged, 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 noSKIP_YAHOOcontrolprevious: the previously published index rows (previousRows);onErrorprints a[ swing ]noteslice(-11, -2)), one swing chart request per refreshed fund (AAA, BBB, CCC) and the values (athBasissince 2025-01-02,athPrice69.9, a number involatility1y); the second one-ticker run still leaves every file unchanged; the mock answers the swing chart URL (period1=0) with 300 daily closes### Metrics and caveatsWhy
Screener plan 1.6, item S5: the swing metrics of the Stocks feed in every ETF brand feed
Checks
swing-gates.sh <repo> baselinebefore 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)TICKERS=IVV ./scripts/update-data.ts(1 updated in 6.2 s):pctFrom52wHigh-2.28,athPrice782.54,athDate2026-10-06,athBasisdaily closes since 2000-05-19,pctFromAth-2.28,volatility1y13.73,sigmaFromMean60d-0.41,high60d782.54,low60d736.21; data discarded (git checkout -- api/)