Files
options-pricer/frontend/surface.html
ojy fc57aecd98 Vol Surface: cache-first load + auto-pick next-month 3rd Friday
On page load and on every symbol Lookup, target the 3rd Friday of
the next calendar month (the standard US monthly options expiry).
If that exact date isn't listed (e.g., June 19, 2026 is Juneteenth
so SPY's monthly is the Thursday 06-18), fall back to the nearest
available expiration.

Data flow:
  1. Init reads {symbol, expirations} from ViewState.
  2. Computes target expiry (3rd Fri next month).
  3. Hits a new per-symbol cache at
     localStorage['optionsPricer:surfaceCache'][symbol:expiry].
     - Hit AND cache.date === today → render instantly, no network.
     - Hit but stale (cache.date !== today) → refetch.
     - Miss → fetch expirations + load surface.
  4. fetchExpirations() now auto-selects the target expiry and
     triggers _loadForTargetExpiry (cache-aware) — entering a new
     symbol now produces a rendered surface with one Enter press.
  5. Successful loadSurface writes the response into the cache
     under today's date; cache is pruned to 50 entries.

Analytics is no longer stuffed into ViewState (only the lightweight
symbol/expirations/expiry pointer is), so the per-symbol cache is
the single source of truth for surface data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 08:08:05 +00:00

49 KiB