From 84d78545c8ba2dfb7ad9e47d91713f583bd57c20 Mon Sep 17 00:00:00 2001 From: heyitsStylez Date: Sun, 10 May 2026 12:27:43 +0800 Subject: [PATCH 1/2] Align Expiring This Week table with Trade Log column order and badge style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Asset and Type now render as colored badges (matching Open Positions/History), and column order matches: Asset | Platform | Type | Strike | Size | DTE | Premium | APR | Status | actions. Renames "Strategy" → "Type". Co-Authored-By: Claude Sonnet 4.6 --- src/js/06-render-table.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/06-render-table.js b/src/js/06-render-table.js index 105cf2a..4142de3 100644 --- a/src/js/06-render-table.js +++ b/src/js/06-render-table.js @@ -214,15 +214,15 @@ function renderExpiryTable() { const rows = enriched.map(e => { const t = e.t; return '' - + '' + t.asset + '' - + '' + t.type + '' + + '' + t.asset + '' + + '' + e.platBadge + '' + + '' + t.type + '' + '$' + fmt(t.strike) + '' + '' + fmt(t.size) + '' + '' + e.dteLabel + '' + '$' + fmt(t.premium) + '' + '' + e.aprHtml + '' + '' + e.statusHtml + '' - + '' + e.platBadge + '' + '' + e.actionsHtml + '' + ''; }).join(''); @@ -248,7 +248,7 @@ function renderExpiryTable() { }).join(''); wrap.innerHTML = '' - + '' + + '' + '' + rows + '' + '
AssetStrategyStrikeSizeDTEPremiumAPRStatusPlatform
AssetPlatformTypeStrikeSizeDTEPremiumAPRStatus
' + '
' + cards + '
'; From edba24230e02754b025b4acf74fbebe327cffd30 Mon Sep 17 00:00:00 2001 From: heyitsStylez Date: Sun, 10 May 2026 12:28:29 +0800 Subject: [PATCH 2/2] Update CONTEXT.md with Premium Statistics term definition Co-Authored-By: Claude Sonnet 4.6 --- CONTEXT.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CONTEXT.md b/CONTEXT.md index 28d6caf..4e2de94 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -174,6 +174,28 @@ read **Term**. Never label a frozen original-DTE column "DTE" — the ambiguity historically led to three identically-labelled columns showing two different numbers. +### Premium Statistics +A gross-premium-income view over a set of Trade rows. Distinct from Realised +P&L (which is a cash-flow lens): Premium Statistics treats premium collected as +the primary signal and derives: + +- **Total premium** — sum of net premiums across all trades in the set +- **Total notional** — Σ strike × size (capital at risk) +- **Portfolio APR** — notional-weighted average APR of settled options: + `(netPrem / collateral) / DTE × 365`, weighted by notional +- **Return rate** — share of settled options that expired OTM (premium kept) +- **OTM / ITM counts** — settled outcome breakdown + +Lives in `src/js/05d-calc-stats.js` as the pure function +`calcPremiumStats(rows) → { totalPrem, totalNotional, portfolioAPR, returnRate, +otmCount, itmCount, openCount, settled, totalCount }`. Dual-exported. Consumed +by `rCharts` for the Premium P&L Total and Monthly tabs. + +Intentionally does **not** include Realised P&L or Unrealised P&L — those live +in `computePnl`. The two functions answer different questions: `computePnl` +answers *"what did this position earn under cash-flow accounting?"*; +`calcPremiumStats` answers *"how is the premium-income engine performing?"* + ### Trade accounting snapshot A per-trade record of the lot state **at the moment that trade was processed** by the engine: `{ lotNum, lotSize, lotPremiums, lotCostBasis }`. Captured