Commit Graph

12 Commits

Author SHA1 Message Date
ojy
03afae3d04 Drag-to-pan the P/L chart price range
Hold the left mouse button on the chart and drag left/right to slide the
underlying-price window; the curve is re-sampled as you drag so it always
extends to the edges. Fit / switching symbols / clear-all re-centre and
reset zoom.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 05:03:49 +00:00
ojy
6ffde10391 Editable strike in legs — re-prices from loaded chain
The Strike cell becomes a dropdown of available strikes (for that leg's
symbol+expiry+type) drawn from the cached chain — seeded from chain.html's
last-loaded chain (localStorage) and refreshed by the strategy page's own
per-expiry chain fetch on open / Reload. Picking a new strike updates the
leg's entry price, IV and mark from that contract and clears the lock.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 05:00:34 +00:00
ojy
957558fc76 Fix unreadable chart annotation labels
Spot / break-even / zero-line labels now use solid high-contrast badges
(dark text on yellow, white text on blue, light text on dark) with padding
and a border instead of transparent/low-contrast backgrounds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:52:47 +00:00
ojy
6ecc69df99 Add price-range zoom controls to the P/L chart
−/+ buttons (with a ±% readout) and a Fit button in the chart header widen
or narrow the underlying-price window the curve is sampled over, so you can
inspect a tight range around spot or zoom out to see the full payoff shape.
Bumped sampling density to 221 points.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:49:23 +00:00
ojy
703c305cf1 Multi-symbol strategy baskets + symbol picker
The store now keeps one basket per symbol (v2 schema, auto-migrates v1).
Adding a leg from a different symbol no longer wipes the basket — it creates
that symbol's basket and makes it active. The Strategy page shows a symbol
picker at the top (when >1 symbol is saved) to switch between them; switching
auto-fetches that symbol's live marks. "Clear all" clears only the current
symbol's legs; new StrategyStore.clearAll() wipes everything.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:47:16 +00:00
ojy
e0cbd798b6 Auto-fetch live marks on strategy page open
On opening the Strategy page, automatically pull the current spot, each leg's
live mid (Mark column) and IV — without touching entry prices. The Reload
button still re-prices unlocked legs to the current mark. Clarified the legs
table hint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:38:07 +00:00
ojy
5348bf643a Round leg prices to 2 decimals everywhere
Entry price, mark and strike are now rounded to 2dp on add, on edit, on
market reload, and on load (self-heals legacy entries) — fixes display of
float artifacts like "15.000000001". Also persist the leg's locked/currentMark
fields in the store.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:28:21 +00:00
ojy
9219220270 Add per-leg entry-price lock + market Reload button
- Each leg has a 🔓/🔒 toggle next to its entry price; locked = entry stays
  fixed (your fill), unlocked = entry re-prices to the current mark on Reload
- New "Mark" column shows each leg's current market mid (with delta vs entry)
- "Refresh spot" button replaced by "Reload": re-fetches spot, plus each leg's
  current mark and IV from the live chain (per unique expiry), re-pricing
  unlocked legs and refreshing IVs used by the T+0 curve
- reload() no longer resets the days-to-expiry slider on edits

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:22:59 +00:00
ojy
fb773869b9 Move legs table to bottom; per-leg show/hide in chart
- Legs table now sits below the P/L chart and stats
- Each leg row has a leftmost "Show" checkbox; unchecked legs are excluded
  from the chart, stats, breakevens and net Greeks (and dimmed in the table),
  so you can isolate or build up a strategy incrementally
- All derived values (chart, netCost, maxDTE/minDTE, strategy name, stats)
  now operate on the active (checked) legs only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:17:07 +00:00
ojy
57473ec271 Sharpen P/L extrema & curve at strike kinks
Evaluate the expiration P/L at the exact strike prices (and sample bounds),
not just on the coarse grid — so max profit / max loss are exact for
piecewise payoffs (butterfly peak now $800 not ~$679) and the chart renders
sharp vertices for butterflies, condors, etc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:12:16 +00:00
ojy
2ebc0eeb20 Fix expiration P/L curve in strategy analyzer
- Use exact (not floored) days-to-earliest-expiry so the "Expiration P/L"
  curve uses true intrinsic value — long call/put now show a flat loss floor
  at -premium, a sharp kink at the strike, and the correct breakeven, instead
  of a soft-cornered curve with ~1 day of residual time value
- Clamp the y-axis when one tail is unbounded so the loss floor stays visible
  instead of being squished to a sliver by the runaway profit/loss tail
- Slightly tighter default x-window; denser sampling (161 pts)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 04:07:26 +00:00
ojy
3109df842d 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