2026-05-13 03:22:23 +00:00
<!doctype html>
< html lang = "en" data-bs-theme = "dark" >
< head >
< meta charset = "utf-8" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1, viewport-fit=cover" / >
< meta http-equiv = "X-UA-Compatible" content = "ie=edge" / >
< title > Options Metrics Tracker< / title >
< link rel = "stylesheet" href = "/assets/tabler.min.css" / >
< link rel = "stylesheet" href = "/assets/tabler-vendors.min.css" / >
< script src = "/assets/apexcharts.min.js" > < / script >
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
< script src = "/assets/viewstate-store.js" > < / script >
2026-05-13 03:22:23 +00:00
< script src = "/assets/alpine.min.js" defer > < / script >
< script src = "/assets/tabler.min.js" defer > < / script >
< style >
:root {
--chart-bg: #1a1c23;
--chart-grid: rgba(255, 255, 255, 0.06);
--chart-label: #8b95a1;
}
body {
background-color: #1a1c23;
}
.navbar-vertical.navbar-dark {
background-color: #14161c;
border-right: 1px solid rgba(255, 255, 255, 0.07);
}
.chart-card {
background-color: var(--chart-bg);
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 8px;
}
.apexcharts-canvas {
background: transparent !important;
}
.table-snapshots th {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--chart-label);
font-weight: 600;
}
.toolbar-bar {
background-color: #14161c;
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.nav-link.active-page {
color: #4fc3f7 !important;
background-color: rgba(79, 195, 247, 0.1) !important;
border-radius: 6px;
}
.badge-fat-tails {
background-color: #f59f00;
color: #1a1c23;
}
.badge-thin-tails {
background-color: #d63939;
color: #fff;
}
.badge-normal {
background-color: rgba(255, 255, 255, 0.1);
color: #8b95a1;
}
.snapshot-count-badge {
font-size: 0.7rem;
padding: 2px 8px;
border-radius: 12px;
background-color: rgba(79, 195, 247, 0.15);
color: #4fc3f7;
border: 1px solid rgba(79, 195, 247, 0.3);
font-weight: 600;
white-space: nowrap;
}
[x-cloak] { display: none !important; }
< / style >
< / head >
< body class = "antialiased" x-data = "trackerApp()" x-init = "init()" >
< div class = "wrapper" >
<!-- Vertical Sidebar -->
< aside class = "navbar navbar-vertical navbar-expand-lg" data-bs-theme = "dark" >
< div class = "container-fluid" >
2026-05-13 07:17:40 +00:00
< button class = "navbar-toggler" type = "button" data-bs-toggle = "collapse" data-bs-target = "#sidebar-menu" aria-controls = "sidebar-menu" aria-expanded = "false" aria-label = "Toggle navigation" >
2026-05-13 03:22:23 +00:00
< span class = "navbar-toggler-icon" > < / span >
< / button >
< h1 class = "navbar-brand navbar-brand-autodark" >
2026-05-13 07:17:40 +00:00
< a href = "index.html" class = "d-flex align-items-center gap-2 text-decoration-none" >
< svg xmlns = "http://www.w3.org/2000/svg" width = "28" height = "28" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "1.5" stroke-linecap = "round" stroke-linejoin = "round" class = "text-primary" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< rect x = "4" y = "8" width = "4" height = "8" rx = "1" / >
< line x1 = "6" y1 = "4" x2 = "6" y2 = "8" / >
< line x1 = "6" y1 = "16" x2 = "6" y2 = "20" / >
< rect x = "16" y = "6" width = "4" height = "10" rx = "1" / >
< line x1 = "18" y1 = "2" x2 = "18" y2 = "6" / >
< line x1 = "18" y1 = "16" x2 = "18" y2 = "22" / >
2026-05-13 03:22:23 +00:00
< / svg >
2026-05-13 07:17:40 +00:00
< span class = "fw-bold" > Options Pricer< / span >
2026-05-13 03:22:23 +00:00
< / a >
< / h1 >
< div class = "collapse navbar-collapse" id = "sidebar-menu" >
< ul class = "navbar-nav pt-lg-3" >
2026-05-13 07:17:40 +00:00
< li class = "nav-item " >
2026-05-13 03:22:23 +00:00
< a class = "nav-link" href = "index.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< rect x = "4" y = "4" width = "6" height = "5" rx = "2" / >
< rect x = "4" y = "13" width = "6" height = "7" rx = "2" / >
< rect x = "14" y = "4" width = "6" height = "11" rx = "2" / >
< rect x = "14" y = "19" width = "6" height = "1" rx = ".5" / >
2026-05-13 03:22:23 +00:00
< / svg >
< / span >
< span class = "nav-link-title" > Dashboard< / span >
< / a >
< / li >
2026-05-13 07:17:40 +00:00
< li class = "nav-item " >
2026-05-13 03:22:23 +00:00
< a class = "nav-link" href = "chain.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< rect x = "3" y = "5" width = "18" height = "14" rx = "2" / >
< path d = "M3 10l18 0" / >
< path d = "M10 5v14" / >
2026-05-13 03:22:23 +00:00
< / svg >
< / span >
< span class = "nav-link-title" > Options Chain< / span >
< / a >
< / li >
2026-05-13 07:17:40 +00:00
< li class = "nav-item " >
2026-05-13 03:22:23 +00:00
< a class = "nav-link" href = "surface.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< path d = "M3 12c1.333 -4.667 2.667 -7 4 -7s2.667 2.333 4 7s2.667 7 4 7s2.667 -2.333 4 -7" / >
2026-05-13 03:22:23 +00:00
< / svg >
< / span >
< span class = "nav-link-title" > Vol Surface< / span >
< / a >
< / li >
IV Spike Scanner
Backend: GET /api/scan?symbols=SYM1,SYM2,... — for each symbol fetches
the front-expiry options chain plus 30-day realized vol and returns
{ spot, change, changePct, atmIv, hv30, ivHv, spike, expiry }. Spike flag
is on when IV/HV ≥ 1.5 or |today's % change| ≥ 3. Defaults to ~15 popular
tickers when no list is given; cap of 30 symbols/scan.
Frontend: new scanner.html page — symbol input (with "Use defaults" / "Use
watchlist" shortcuts), summary cards (count · spikes · biggest mover ·
highest IV/HV), sortable results table with spike rows highlighted, and
shortcut buttons to open each symbol on Chain or Surface.
Scanner added to all sidebars between Vol Surface and Strategy P/L.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 07:32:14 +00:00
Add Top Movers screener (mid-cap+, options-tradable)
New /movers page surfaces Yahoo Finance's predefined screeners
(day_gainers, day_losers, most_actives, most_shorted_stocks)
filtered to common equities with market cap >= $2B, so every
listed name has a deep options chain. Per-row actions jump
straight into Chain / Vol Surface / IV Spike Scanner, or pin
the symbol to the Tracker watchlist.
- datafetch.ts: fetchMovers(category, count) using yf.screener,
post-filtered to quoteType=EQUITY and marketCap >= $2B
- options.ts: GET /api/movers?category=&count=
- movers.html: Tabler page with 4-tab segmented control, sortable
table, summary cards, volume-vs-avg ratio highlighting hot names
- All page sidebars: insert "Movers" link between Vol Surface
and Scanner
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 07:47:32 +00:00
< li class = "nav-item" >
< a class = "nav-link" href = "movers.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< path d = "M3 17l6 -6l4 4l8 -8" / >
< path d = "M14 7l7 0l0 7" / >
< / svg >
< / span >
< span class = "nav-link-title" > Movers< / span >
< / a >
< / li >
IV Spike Scanner
Backend: GET /api/scan?symbols=SYM1,SYM2,... — for each symbol fetches
the front-expiry options chain plus 30-day realized vol and returns
{ spot, change, changePct, atmIv, hv30, ivHv, spike, expiry }. Spike flag
is on when IV/HV ≥ 1.5 or |today's % change| ≥ 3. Defaults to ~15 popular
tickers when no list is given; cap of 30 symbols/scan.
Frontend: new scanner.html page — symbol input (with "Use defaults" / "Use
watchlist" shortcuts), summary cards (count · spikes · biggest mover ·
highest IV/HV), sortable results table with spike rows highlighted, and
shortcut buttons to open each symbol on Chain or Surface.
Scanner added to all sidebars between Vol Surface and Strategy P/L.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 07:32:14 +00:00
< li class = "nav-item" >
< a class = "nav-link" href = "scanner.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< circle cx = "11" cy = "11" r = "7" / >
< line x1 = "21" y1 = "21" x2 = "16.65" y2 = "16.65" / >
< path d = "M11 8v6" / >
< path d = "M8 11h6" / >
< / svg >
< / span >
< span class = "nav-link-title" > Scanner< / span >
< / a >
< / li >
2026-05-13 07:17:40 +00:00
< li class = "nav-item " >
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
< a class = "nav-link" href = "strategy.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< path d = "M4 19l4 -6l4 2l4 -8l4 5" / >
< path d = "M4 4v16h16" / >
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
< / svg >
< / span >
< span class = "nav-link-title" > Strategy P/L< / span >
< / a >
< / li >
2026-05-13 07:17:40 +00:00
< li class = "nav-item " >
2026-05-13 07:04:52 +00:00
< a class = "nav-link" href = "positions.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< rect x = "3" y = "7" width = "18" height = "13" rx = "2" / >
< path d = "M8 7v-2a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v2" / >
< line x1 = "12" y1 = "12" x2 = "12" y2 = "12.01" / >
< path d = "M3 13a20 20 0 0 0 18 0" / >
2026-05-13 07:04:52 +00:00
< / svg >
< / span >
< span class = "nav-link-title" > Positions< / span >
< / a >
< / li >
2026-05-13 07:17:40 +00:00
< li class = "nav-item active" >
< a class = "nav-link" href = "tracker.html" >
2026-05-13 03:22:23 +00:00
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< path d = "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" / >
< path d = "M12 12m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0" / >
< path d = "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" / >
< path d = "M15 12l-3 -3" / >
2026-05-13 03:22:23 +00:00
< / svg >
< / span >
< span class = "nav-link-title" > Tracker< / span >
< / a >
< / li >
2026-05-13 07:17:40 +00:00
< li class = "nav-item " >
2026-05-13 07:04:52 +00:00
< a class = "nav-link" href = "settings.html" >
< span class = "nav-link-icon d-md-none d-lg-inline-block" >
2026-05-13 07:17:40 +00:00
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" aria-hidden = "true" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< path d = "M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" / >
2026-05-13 07:04:52 +00:00
< circle cx = "12" cy = "12" r = "3" / >
< / svg >
< / span >
< span class = "nav-link-title" > Settings< / span >
< / a >
< / li >
2026-05-13 03:22:23 +00:00
< / ul >
< / div >
< / div >
< / aside >
<!-- Main content -->
< div class = "page-wrapper" >
<!-- Toolbar -->
< div class = "toolbar-bar py-2 px-3 mb-3" >
< div class = "container-xl" >
< div class = "d-flex flex-wrap align-items-center gap-3" >
<!-- Symbol input -->
< div class = "input-group input-group-sm" style = "max-width:140px;" >
< span class = "input-group-text bg-dark border-secondary text-muted" > Symbol< / span >
< input
type="text"
class="form-control bg-dark border-secondary text-white"
placeholder="SPY"
x-model="symbol"
@keydown.enter="fetchExpirations()"
style="text-transform:uppercase;"
/>
< / div >
<!-- Expiry select -->
< div class = "input-group input-group-sm" style = "max-width:200px;" >
< span class = "input-group-text bg-dark border-secondary text-muted" > Expiry< / span >
< select
class="form-select bg-dark border-secondary text-white"
x-model="expiry"
@change="renderCharts()"
>
< option value = "" > All expirations< / option >
< template x-for = "exp in expirations" :key = "exp" >
< option :value = "exp" x-text = "exp" > < / option >
< / template >
< / select >
< / div >
<!-- Load button -->
< button
class="btn btn-sm btn-primary"
@click="loadHistory()"
:disabled="loading"
>
< span x-show = "loading" class = "spinner-border spinner-border-sm me-1" role = "status" > < / span >
< span x-show = "!loading" >
< svg xmlns = "http://www.w3.org/2000/svg" width = "14" height = "14" viewBox = "0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"
class="me-1" style="vertical-align:-2px;">
< polyline points = "1 4 1 10 7 10" > < / polyline >
< path d = "M3.51 15a9 9 0 1 0 .49-3.51" > < / path >
< / svg >
Load History
< / span >
< span x-show = "loading" > Loading…< / span >
< / button >
<!-- Snapshot count badge -->
< span class = "snapshot-count-badge" x-text = "filteredSnapshots.length + ' snapshots'" > < / span >
<!-- Error message -->
< span x-show = "error" x-cloak class = "text-danger small ms-2" x-text = "error" > < / span >
< / div >
< / div >
< / div >
<!-- Page body -->
< div class = "page-body" >
< div class = "container-xl" >
2026-05-13 07:14:06 +00:00
<!-- Watchlist summary cards (symbols saved from Strategy page) -->
< div class = "mb-3" x-show = "watchlist.length > 0" x-cloak >
< div class = "d-flex align-items-center justify-content-between mb-2" >
< h3 class = "text-white mb-0" style = "font-size:1rem;" > Watchlist < span class = "text-secondary small fw-normal" x-text = "'(' + watchlist.length + ')'" > < / span > < / h3 >
< button class = "btn btn-sm btn-outline-secondary" @ click = "_loadWatchlistData()" :disabled = "watchlistLoading" >
< span x-show = "watchlistLoading" class = "spinner-border spinner-border-sm me-1" > < / span > Refresh
< / button >
< / div >
< div class = "row g-2" >
< template x-for = "s in watchlist" :key = "s" >
< div class = "col-6 col-md-4 col-lg-3 col-xl-2" >
< div class = "watch-card" style = "background:#1e2030; border:1px solid #2d3045; border-radius:.5rem; padding:.6rem .75rem; cursor:pointer;"
:class="s === symbol.toUpperCase().trim() ? 'border-primary' : ''"
:style="s === symbol.toUpperCase().trim() ? 'background:#1e2030; border:1px solid #4d9ef7; border-radius:.5rem; padding:.6rem .75rem; cursor:pointer;' : 'background:#1e2030; border:1px solid #2d3045; border-radius:.5rem; padding:.6rem .75rem; cursor:pointer;'"
@click="loadSymbol(s)">
< div class = "d-flex align-items-center justify-content-between" >
< span class = "fw-bold text-white" style = "font-family:'JetBrains Mono',monospace;" x-text = "s" > < / span >
< span class = "text-danger small" style = "cursor:pointer;" @ click . stop = "removeWatch(s)" :title = "'Remove ' + s" > ✕< / span >
< / div >
< div class = "mt-1" style = "font-size:.78rem; color:#cbd3df;" >
< template x-if = "watchlistData[s]" >
< div >
< div > Spot < strong class = "mono" x-text = "watchlistData[s].spot ? '$' + watchlistData[s].spot.toFixed(2) : '—'" > < / strong > < / div >
< div > ATM IV < strong class = "mono" :style = "watchlistData[s].atmIv > 0.4 ? 'color:#ff8c42' : watchlistData[s].atmIv > 0.2 ? 'color:#ffd43b' : 'color:#51cf66'" x-text = "watchlistData[s].atmIv ? (watchlistData[s].atmIv*100).toFixed(1) + '%' : '—'" > < / strong > < / div >
< div :style = "watchlistData[s].rr25 > 0.005 ? 'color:#51cf66' : watchlistData[s].rr25 < -0.005 ? 'color:#ff6b6b' : 'color:#8b95a7'" >
RR25 < span class = "mono" x-text = "watchlistData[s].rr25 != null ? ((watchlistData[s].rr25 >= 0 ? '+' : '') + (watchlistData[s].rr25 * 100).toFixed(2) + '%') : '—'" > < / span >
< / div >
< / div >
< / template >
< template x-if = "!watchlistData[s]" > < div class = "text-secondary" > loading…< / div > < / template >
< / div >
< / div >
< / div >
< / template >
< / div >
Tracked orders — persist strategy positions in SQLite
Backend:
- New orders table (symbol, name, legs_json, entry_cost, created_at,
closed_at, status, note) sharing the snapshots.db
- Endpoints:
POST /api/orders save a position
GET /api/orders?symbol= list (most recent first)
GET /api/orders/:id single
PATCH /api/orders/:id { status:'open'|'closed', note? }
DELETE /api/orders/:id remove
Strategy page:
- "Save to Tracker" button posts the currently-active legs (with name,
net cost, side, qty, entry, IV, lock) as an order
Tracker page:
- New "Tracked Orders" section above the IV history charts: lists each
saved position for the current symbol with strategy name, leg summary,
entered cost, current value, P/L $ and %, opened date, status, and
Close/Reopen + Remove actions. Live P/L uses /api/chain mids for each
unique leg expiry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 06:54:40 +00:00
< / div >
2026-05-13 03:22:23 +00:00
<!-- Empty state -->
< div x-show = "!loading && filteredSnapshots.length === 0" x-cloak class = "text-center py-5" >
< svg xmlns = "http://www.w3.org/2000/svg" width = "48" height = "48" viewBox = "0 0 24 24"
fill="none" stroke="#8b95a1" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="mb-3">
< path d = "M3 3l18 18" > < / path >
< path d = "M21 21l-1.5-1.5M16.5 16.5L12 12M12 12L7.5 7.5M7.5 7.5L3 3" > < / path >
< circle cx = "12" cy = "12" r = "10" > < / circle >
< / svg >
2026-05-13 07:14:06 +00:00
< p class = "text-muted" >
No snapshot data yet. < span x-show = "watchlist.length > 0" > Click a watchlist card above, or < / span > enter a symbol and click < strong > Load History< / strong > .
< br >
< span class = "small" > Tip: add symbols to the watchlist from the < a href = "strategy.html" > Strategy< / a > page's < em > Save to Tracker< / em > button.< / span >
< / p >
2026-05-13 03:22:23 +00:00
< / div >
<!-- Charts row -->
< div x-show = "filteredSnapshots.length > 0" x-cloak >
< div class = "row g-3 mb-3" >
<!-- Chart 1: ATM IV -->
< div class = "col-12" >
< div class = "chart-card p-3" >
< div class = "d-flex align-items-center mb-2 gap-2" >
< span style = "display:inline-block;width:10px;height:10px;border-radius:50%;background:#00d4ff;" > < / span >
< span class = "fw-semibold text-white" style = "font-size:0.9rem;" > ATM Implied Volatility History< / span >
< / div >
< div id = "chart-atm-iv" style = "min-height:220px;" > < / div >
< / div >
< / div >
<!-- Chart 2: RR25 + Chart 3: Fly25 side by side on wider screens -->
< div class = "col-12 col-lg-6" >
< div class = "chart-card p-3" >
< div class = "d-flex align-items-center mb-2 gap-2" >
< span style = "display:inline-block;width:10px;height:10px;border-radius:50%;background:#2fb344;" > < / span >
< span class = "fw-semibold text-white" style = "font-size:0.9rem;" > 25Δ Risk Reversal History< / span >
< / div >
< div id = "chart-rr25" style = "min-height:220px;" > < / div >
< / div >
< / div >
< div class = "col-12 col-lg-6" >
< div class = "chart-card p-3" >
< div class = "d-flex align-items-center mb-2 gap-2" >
< span style = "display:inline-block;width:10px;height:10px;border-radius:50%;background:#f59f00;" > < / span >
< span class = "fw-semibold text-white" style = "font-size:0.9rem;" > 25Δ Butterfly History< / span >
< / div >
< div id = "chart-fly25" style = "min-height:220px;" > < / div >
< / div >
< / div >
< / div >
<!-- History table -->
< div class = "card" style = "background-color:#14161c; border:1px solid rgba(255,255,255,0.07);" >
< div class = "card-header d-flex align-items-center justify-content-between"
style="border-bottom:1px solid rgba(255,255,255,0.07);">
< h3 class = "card-title text-white mb-0" style = "font-size:0.9rem; font-weight:600;" >
Snapshot History
< span class = "ms-2 text-muted" style = "font-size:0.75rem; font-weight:400;" >
(most recent first, showing up to 20)
< / span >
< / h3 >
< / div >
< div class = "table-responsive" >
< table class = "table table-sm table-hover table-snapshots mb-0"
style="color:#c8d3e0;">
< thead >
< tr >
< th > Timestamp< / th >
< th > Expiry< / th >
< th > Spot< / th >
< th > ATM IV< / th >
< th > RR25< / th >
< th > RR10< / th >
< th > Fly25< / th >
< th > Butterfly Signal< / th >
< / tr >
< / thead >
< tbody >
< template x-for = "(snap, idx) in tableRows" :key = "snap.timestamp + idx" >
< tr >
< td class = "text-muted" style = "white-space:nowrap; font-size:0.8rem;"
x-text="formatTimestamp(snap.timestamp)">< / td >
< td x-text = "snap.expiry || '—'" > < / td >
< td x-text = "snap.spot ? snap.spot.toFixed(2) : '—'" > < / td >
< td >
< span x-text = "snap.atmIv ? (snap.atmIv * 100).toFixed(2) + '%' : '—'"
style="color:#4fc3f7; font-variant-numeric:tabular-nums;">< / span >
< / td >
< td >
< span
:style="{ color: snap.rr25 > 0 ? '#2fb344' : snap.rr25 < 0 ? ' # d63939 ' : ' # 8b95a1 ' } "
style="font-variant-numeric:tabular-nums;"
x-text="snap.rr25 != null ? snap.rr25.toFixed(4) : '—'">
< / span >
< / td >
< td >
< span
:style="{ color: snap.rr10 > 0 ? '#2fb344' : snap.rr10 < 0 ? ' # d63939 ' : ' # 8b95a1 ' } "
style="font-variant-numeric:tabular-nums;"
x-text="snap.rr10 != null ? snap.rr10.toFixed(4) : '—'">
< / span >
< / td >
< td style = "font-variant-numeric:tabular-nums;"
x-text="snap.fly25 != null ? snap.fly25.toFixed(4) : '—'">< / td >
< td >
< template x-if = "snap.fly25 > 0.002" >
< span class = "badge badge-fat-tails" > Fat Tails< / span >
< / template >
< template x-if = "snap.fly25 <= 0.002 && snap.fly25 < -0.002" >
< span class = "badge badge-thin-tails" > Thin Tails< / span >
< / template >
< template x-if = "snap.fly25 != null && snap.fly25 >= -0.002 && snap.fly25 <= 0.002" >
< span class = "badge badge-normal" > Normal< / span >
< / template >
< template x-if = "snap.fly25 == null" >
< span class = "text-muted" > —< / span >
< / template >
< / td >
< / tr >
< / template >
< tr x-show = "tableRows.length === 0" >
< td colspan = "8" class = "text-center text-muted py-3" > No data available< / td >
< / tr >
< / tbody >
< / table >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
<!-- Alpine + ApexCharts logic -->
< script >
const CHART_DEFAULTS = {
background: 'transparent',
foreColor: '#8b95a1',
fontFamily: 'inherit',
};
const AXIS_STYLE = {
borderColor: 'rgba(255,255,255,0.06)',
labels: {
style: { colors: '#8b95a1', fontSize: '11px' }
},
axisBorder: { show: false },
axisTicks: { show: false },
};
const TOOLTIP_STYLE = {
theme: 'dark',
};
const GRID_STYLE = {
borderColor: 'rgba(255,255,255,0.06)',
strokeDashArray: 4,
};
// ── ATM IV chart ──────────────────────────────────────────────────────────
function buildAtmIvChart(data) {
const sorted = [...data].sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
const series = sorted.map(s => ({
x: new Date(s.timestamp).getTime(),
y: s.atmIv != null ? parseFloat((s.atmIv * 100).toFixed(4)) : null,
})).filter(p => p.y !== null);
const options = {
chart: {
type: 'area',
height: 220,
toolbar: { show: false },
...CHART_DEFAULTS,
animations: { enabled: true, speed: 400 },
zoom: { enabled: false },
},
series: [{ name: 'ATM IV', data: series }],
stroke: { curve: 'smooth', width: 2, colors: ['#00d4ff'] },
fill: {
type: 'gradient',
gradient: {
shadeIntensity: 1,
opacityFrom: 0.2,
opacityTo: 0.0,
stops: [0, 100],
colorStops: [{
offset: 0,
color: '#00d4ff',
opacity: 0.2,
}, {
offset: 100,
color: '#00d4ff',
opacity: 0,
}],
},
},
colors: ['#00d4ff'],
xaxis: {
type: 'datetime',
...AXIS_STYLE,
},
yaxis: {
...AXIS_STYLE,
labels: {
style: { colors: '#8b95a1', fontSize: '11px' },
formatter: v => v != null ? v.toFixed(1) + '%' : '',
},
title: { text: 'IV (%)', style: { color: '#8b95a1', fontSize: '11px', fontWeight: 400 } },
},
grid: GRID_STYLE,
tooltip: {
...TOOLTIP_STYLE,
x: { format: 'dd MMM yy HH:mm' },
y: { formatter: v => v != null ? v.toFixed(2) + '%' : 'N/A' },
},
markers: { size: series.length < = 15 ? 4 : 0, colors: ['#00d4ff'], strokeColors: '#1a1c23', strokeWidth: 2 },
dataLabels: { enabled: false },
};
return options;
}
// ── RR25 chart ────────────────────────────────────────────────────────────
function buildRr25Chart(data) {
const sorted = [...data].sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
const series = sorted.map(s => ({
x: new Date(s.timestamp).getTime(),
y: s.rr25 != null ? parseFloat(s.rr25.toFixed(6)) : null,
})).filter(p => p.y !== null);
const options = {
chart: {
type: 'line',
height: 220,
toolbar: { show: false },
...CHART_DEFAULTS,
animations: { enabled: true, speed: 400 },
zoom: { enabled: false },
},
series: [{ name: 'RR25', data: series }],
stroke: { curve: 'smooth', width: 2, colors: ['#2fb344'] },
colors: ['#2fb344'],
xaxis: {
type: 'datetime',
...AXIS_STYLE,
},
yaxis: {
...AXIS_STYLE,
labels: {
style: { colors: '#8b95a1', fontSize: '11px' },
formatter: v => v != null ? v.toFixed(4) : '',
},
title: { text: 'RR25', style: { color: '#8b95a1', fontSize: '11px', fontWeight: 400 } },
},
grid: GRID_STYLE,
annotations: {
yaxis: [{
y: 0,
borderColor: 'rgba(255, 255, 255, 0.25)',
strokeDashArray: 5,
label: {
text: 'Zero',
style: {
color: '#8b95a1',
background: 'transparent',
fontSize: '10px',
},
position: 'right',
},
}],
},
tooltip: {
...TOOLTIP_STYLE,
x: { format: 'dd MMM yy HH:mm' },
y: { formatter: v => v != null ? v.toFixed(4) : 'N/A' },
},
markers: { size: series.length < = 15 ? 4 : 0, colors: ['#2fb344'], strokeColors: '#1a1c23', strokeWidth: 2 },
dataLabels: { enabled: false },
};
return options;
}
// ── Fly25 chart ───────────────────────────────────────────────────────────
function buildFly25Chart(data) {
const sorted = [...data].sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
const filtered = sorted.filter(s => s.fly25 != null);
const values = filtered.map(s => parseFloat(s.fly25.toFixed(6)));
const timestamps = filtered.map(s => new Date(s.timestamp).getTime());
const barColors = values.map(v => v > 0 ? '#f59f00' : '#6c757d');
const options = {
chart: {
type: 'bar',
height: 220,
toolbar: { show: false },
...CHART_DEFAULTS,
animations: { enabled: true, speed: 400 },
zoom: { enabled: false },
},
series: [{
name: 'Fly25',
data: filtered.map((s, i) => ({
x: timestamps[i],
y: values[i],
})),
}],
plotOptions: {
bar: {
distributed: true,
borderRadius: 2,
columnWidth: filtered.length > 30 ? '90%' : '60%',
},
},
colors: barColors,
legend: { show: false },
xaxis: {
type: 'datetime',
...AXIS_STYLE,
},
yaxis: {
...AXIS_STYLE,
labels: {
style: { colors: '#8b95a1', fontSize: '11px' },
formatter: v => v != null ? v.toFixed(4) : '',
},
title: { text: 'Fly25', style: { color: '#8b95a1', fontSize: '11px', fontWeight: 400 } },
},
grid: GRID_STYLE,
annotations: {
yaxis: [{
y: 0,
borderColor: 'rgba(255, 255, 255, 0.2)',
strokeDashArray: 4,
}],
},
tooltip: {
...TOOLTIP_STYLE,
x: { format: 'dd MMM yy HH:mm' },
y: { formatter: v => v != null ? v.toFixed(4) : 'N/A' },
},
dataLabels: { enabled: false },
};
return options;
}
// ── Alpine component ──────────────────────────────────────────────────────
function trackerApp() {
return {
symbol: 'SPY',
expiry: '',
expirations: [],
snapshots: [],
loading: false,
error: '',
2026-05-13 07:04:52 +00:00
watchlist: [],
2026-05-13 07:14:06 +00:00
watchlistData: {},
watchlistLoading: false,
Tracked orders — persist strategy positions in SQLite
Backend:
- New orders table (symbol, name, legs_json, entry_cost, created_at,
closed_at, status, note) sharing the snapshots.db
- Endpoints:
POST /api/orders save a position
GET /api/orders?symbol= list (most recent first)
GET /api/orders/:id single
PATCH /api/orders/:id { status:'open'|'closed', note? }
DELETE /api/orders/:id remove
Strategy page:
- "Save to Tracker" button posts the currently-active legs (with name,
net cost, side, qty, entry, IV, lock) as an order
Tracker page:
- New "Tracked Orders" section above the IV history charts: lists each
saved position for the current symbol with strategy name, leg summary,
entered cost, current value, P/L $ and %, opened date, status, and
Close/Reopen + Remove actions. Live P/L uses /api/chain mids for each
unique leg expiry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 06:54:40 +00:00
2026-05-13 03:22:23 +00:00
_charts: { atmIv: null, rr25: null, fly25: null },
async init() {
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
// restore last loaded history (survives navigating away & back)
const vs = ViewState.load('tracker');
if (vs) {
this.symbol = vs.symbol ?? this.symbol;
this.expirations = vs.expirations ?? [];
this.expiry = vs.expiry ?? '';
this.snapshots = vs.snapshots ?? [];
if (this.snapshots.length) this.$nextTick(() => this.renderCharts());
}
2026-05-13 07:04:52 +00:00
this._loadWatchlist();
2026-05-13 07:14:06 +00:00
window.addEventListener('storage', (e) => { if (e.key === 'optionsPricer:watchlist') { this._loadWatchlist(); this._loadWatchlistData(); } });
// populate the watchlist cards
if (this.watchlist.length) this._loadWatchlistData();
// if we have nothing loaded yet but a watchlist exists, auto-open the first
if (this.snapshots.length === 0 & & this.watchlist.length > 0) {
this.loadSymbol(this.watchlist[0]);
}
Tracked orders — persist strategy positions in SQLite
Backend:
- New orders table (symbol, name, legs_json, entry_cost, created_at,
closed_at, status, note) sharing the snapshots.db
- Endpoints:
POST /api/orders save a position
GET /api/orders?symbol= list (most recent first)
GET /api/orders/:id single
PATCH /api/orders/:id { status:'open'|'closed', note? }
DELETE /api/orders/:id remove
Strategy page:
- "Save to Tracker" button posts the currently-active legs (with name,
net cost, side, qty, entry, IV, lock) as an order
Tracker page:
- New "Tracked Orders" section above the IV history charts: lists each
saved position for the current symbol with strategy name, leg summary,
entered cost, current value, P/L $ and %, opened date, status, and
Close/Reopen + Remove actions. Live P/L uses /api/chain mids for each
unique leg expiry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 06:54:40 +00:00
},
2026-05-13 07:04:52 +00:00
_loadWatchlist() {
try { this.watchlist = JSON.parse(localStorage.getItem('optionsPricer:watchlist') || '[]'); }
catch { this.watchlist = []; }
Tracked orders — persist strategy positions in SQLite
Backend:
- New orders table (symbol, name, legs_json, entry_cost, created_at,
closed_at, status, note) sharing the snapshots.db
- Endpoints:
POST /api/orders save a position
GET /api/orders?symbol= list (most recent first)
GET /api/orders/:id single
PATCH /api/orders/:id { status:'open'|'closed', note? }
DELETE /api/orders/:id remove
Strategy page:
- "Save to Tracker" button posts the currently-active legs (with name,
net cost, side, qty, entry, IV, lock) as an order
Tracker page:
- New "Tracked Orders" section above the IV history charts: lists each
saved position for the current symbol with strategy name, leg summary,
entered cost, current value, P/L $ and %, opened date, status, and
Close/Reopen + Remove actions. Live P/L uses /api/chain mids for each
unique leg expiry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 06:54:40 +00:00
},
2026-05-13 07:14:06 +00:00
async _loadWatchlistData() {
if (this.watchlist.length === 0) return;
this.watchlistLoading = true;
try {
const data = { ...this.watchlistData };
// fetch each symbol's nearest analytics in parallel
await Promise.all(this.watchlist.map(async (sym) => {
try {
const r = await fetch('/api/analytics?symbol=' + encodeURIComponent(sym));
if (!r.ok) return;
const e = await r.json();
const d = e.data ?? e;
// skewMetrics is keyed by expiry — pick the nearest
const expiries = (d.volSurface?.expiries || Object.keys(d.skewMetrics || {})).sort();
const front = expiries[0];
const m = (d.skewMetrics || {})[front] || {};
data[sym] = {
spot: d.spot ?? null,
atmIv: m.atmIv ?? d.atmIv ?? null,
rr25: m.rr25 ?? null,
fly25: m.fly25 ?? null,
expiry: front || null,
ts: new Date().toISOString(),
};
} catch {}
}));
this.watchlistData = data;
} finally {
this.watchlistLoading = false;
}
},
2026-05-13 07:04:52 +00:00
loadSymbol(s) {
this.symbol = s;
this.fetchExpirations();
this.loadHistory();
Tracked orders — persist strategy positions in SQLite
Backend:
- New orders table (symbol, name, legs_json, entry_cost, created_at,
closed_at, status, note) sharing the snapshots.db
- Endpoints:
POST /api/orders save a position
GET /api/orders?symbol= list (most recent first)
GET /api/orders/:id single
PATCH /api/orders/:id { status:'open'|'closed', note? }
DELETE /api/orders/:id remove
Strategy page:
- "Save to Tracker" button posts the currently-active legs (with name,
net cost, side, qty, entry, IV, lock) as an order
Tracker page:
- New "Tracked Orders" section above the IV history charts: lists each
saved position for the current symbol with strategy name, leg summary,
entered cost, current value, P/L $ and %, opened date, status, and
Close/Reopen + Remove actions. Live P/L uses /api/chain mids for each
unique leg expiry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 06:54:40 +00:00
},
2026-05-13 07:04:52 +00:00
removeWatch(s) {
this.watchlist = this.watchlist.filter(x => x !== s);
try { localStorage.setItem('optionsPricer:watchlist', JSON.stringify(this.watchlist)); } catch {}
2026-05-13 07:14:06 +00:00
delete this.watchlistData[s];
// keep reactivity by reassigning
this.watchlistData = { ...this.watchlistData };
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
},
_persist() {
ViewState.save('tracker', {
symbol: this.symbol, expirations: this.expirations,
expiry: this.expiry, snapshots: this.snapshots,
});
2026-05-13 03:22:23 +00:00
},
async fetchExpirations() {
if (!this.symbol.trim()) return;
try {
const sym = this.symbol.trim().toUpperCase();
const res = await fetch(`/api/expirations?symbol=${encodeURIComponent(sym)}`);
if (!res.ok) throw new Error('Failed to fetch expirations');
const env = await res.json();
const json = env.data ?? env;
this.expirations = Array.isArray(json) ? json : (json.expirations || []);
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
this._persist();
2026-05-13 03:22:23 +00:00
} catch (e) {
this.expirations = [];
}
},
async loadHistory() {
if (!this.symbol.trim()) return;
this.loading = true;
this.error = '';
try {
const sym = this.symbol.trim().toUpperCase();
const url = `/api/snapshots?symbol=${encodeURIComponent(sym)}&limit=100`;
const res = await fetch(url);
if (!res.ok) throw new Error(`API error ${res.status}: ${res.statusText}`);
const env = await res.json();
const json = env.data ?? env;
// Accept array or { snapshots: [...] }
this.snapshots = json.snapshots ?? (Array.isArray(json) ? json : []);
// Sort descending (most recent first)
this.snapshots.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
// Rebuild expiration list from data if API didn't provide it
if (this.expirations.length === 0) {
const expSet = new Set(this.snapshots.map(s => s.expiry).filter(Boolean));
this.expirations = [...expSet].sort();
}
Add strategy P/L analyzer + view-state persistence
- New strategy.html: thinkorswim-style P/L diagram (expiration + T+N curves
via Black-Scholes, days-to-expiry slider, net debit/credit, max profit/loss
with unbounded detection, breakevens, net Greeks, auto-detected strategy name)
- chain.html: per-row Buy/Sell buttons add legs to a localStorage basket;
basket badge in toolbar; auto-scroll to ATM row on load
- Persist per-page view state (symbol, expiry, loaded data, charts) across
navigation via viewstate-store.js for chain/surface/tracker/dashboard
- New assets: blackscholes.js (frontend BS port), strategy-store.js, viewstate-store.js
- Strategy P/L nav link added to all sidebars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:01:57 +00:00
this._persist();
2026-05-13 03:22:23 +00:00
this.$nextTick(() => this.renderCharts());
} catch (e) {
this.error = e.message;
this.snapshots = [];
} finally {
this.loading = false;
}
},
get filteredSnapshots() {
if (!this.expiry) return this.snapshots;
return this.snapshots.filter(s => s.expiry === this.expiry);
},
get tableRows() {
// Most recent first, limited to 20
return this.filteredSnapshots.slice(0, 20);
},
formatTimestamp(ts) {
if (!ts) return '—';
try {
const d = new Date(ts);
return d.toLocaleString('en-US', {
month: 'short', day: '2-digit',
hour: '2-digit', minute: '2-digit',
hour12: false,
});
} catch {
return ts;
}
},
renderCharts() {
const data = this.filteredSnapshots;
// Destroy existing instances
Object.keys(this._charts).forEach(k => {
if (this._charts[k]) {
try { this._charts[k].destroy(); } catch (_) {}
this._charts[k] = null;
}
});
if (data.length === 0) return;
this._charts.atmIv = new ApexCharts(
document.querySelector('#chart-atm-iv'),
buildAtmIvChart(data)
);
this._charts.atmIv.render();
this._charts.rr25 = new ApexCharts(
document.querySelector('#chart-rr25'),
buildRr25Chart(data)
);
this._charts.rr25.render();
this._charts.fly25 = new ApexCharts(
document.querySelector('#chart-fly25'),
buildFly25Chart(data)
);
this._charts.fly25.render();
},
// Re-render charts when expiry filter changes
// (triggered via @change on the select, which calls renderCharts() directly)
};
}
< / script >
< / body >
< / html >