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>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
<link rel="stylesheet" href="/assets/tabler.min.css">
|
||||
<link rel="stylesheet" href="/assets/tabler-vendors.min.css">
|
||||
<script src="/assets/apexcharts.min.js"></script>
|
||||
<script src="/assets/viewstate-store.js"></script>
|
||||
<script src="/assets/tabler.min.js" defer></script>
|
||||
<script src="/assets/alpine.min.js" defer></script>
|
||||
|
||||
@@ -200,6 +201,18 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Strategy P/L -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="strategy.html">
|
||||
<span class="nav-link-icon d-md-none d-lg-inline-block">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M4 19l4 -6l4 2l4 -8l4 5"/><path d="M4 4v16h16"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="nav-link-title">Strategy P/L</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Tracker -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="tracker.html">
|
||||
@@ -741,7 +754,16 @@
|
||||
|
||||
// ---- lifecycle ----
|
||||
async init() {
|
||||
// restore last symbol/expiry so navigating back keeps your selection
|
||||
const vs = ViewState.load('dashboard');
|
||||
if (vs) {
|
||||
this.symbol = vs.symbol ?? this.symbol;
|
||||
this.expiry = vs.expiry ?? '';
|
||||
}
|
||||
await this.fetchExpirations();
|
||||
if (this.expiry && !this.expirations.includes(this.expiry)) {
|
||||
this.expiry = this.expirations[0] || '';
|
||||
}
|
||||
if (this.expiry) await this.loadData();
|
||||
},
|
||||
|
||||
@@ -783,6 +805,7 @@
|
||||
this.snapshots = snapshotEnv.data?.snapshots ?? snapshotEnv.snapshots ?? [];
|
||||
|
||||
this.lastUpdated = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
ViewState.save('dashboard', { symbol: this.symbol, expiry: this.expiry });
|
||||
|
||||
// Wait a tick for DOM, then render charts
|
||||
await this.$nextTick();
|
||||
|
||||
Reference in New Issue
Block a user