- 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>
29 lines
850 B
JavaScript
29 lines
850 B
JavaScript
/**
|
|
* Per-page view-state persistence — survives navigation within the app.
|
|
* Exposed as window.ViewState. No modules, no deps.
|
|
*
|
|
* Each page stores its last-loaded inputs + data under
|
|
* localStorage["optionsPricer:view:<page>"] so navigating away and back
|
|
* restores the page exactly as it was.
|
|
*/
|
|
(function () {
|
|
"use strict";
|
|
const PREFIX = "optionsPricer:view:";
|
|
window.ViewState = {
|
|
PREFIX,
|
|
load(page) {
|
|
try {
|
|
const raw = localStorage.getItem(PREFIX + page);
|
|
return raw ? JSON.parse(raw) : null;
|
|
} catch { return null; }
|
|
},
|
|
save(page, data) {
|
|
try { localStorage.setItem(PREFIX + page, JSON.stringify(data)); }
|
|
catch (e) { console.warn("[ViewState] save failed:", e); }
|
|
},
|
|
clear(page) {
|
|
try { localStorage.removeItem(PREFIX + page); } catch {}
|
|
},
|
|
};
|
|
})();
|