From ef459facfca4af33236c0b56aa3bce77ed843fa5 Mon Sep 17 00:00:00 2001 From: Manohar Date: Wed, 27 May 2026 14:00:41 +0530 Subject: [PATCH] feat: reorder cards (payoff below positions), booked=totalRealised, payoff respects expiry tab --- public/index.html | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/public/index.html b/public/index.html index e7ce7a7..51e5d3a 100644 --- a/public/index.html +++ b/public/index.html @@ -156,7 +156,7 @@
Unrealised P&L
Open positions MTM
-
Realised P&L
Booked today (netqty=0)
+
Realised P&L
Partial + full exits today
Total P&L
Unrealised + Realised
@@ -196,8 +196,33 @@ Portfolio Total———
- - +
+
+ Strategy Payoff at Expiry +
+ + +
+ +
+
+
+
NET PREMIUM
+
MAX PROFIT
+
MAX LOSS
+
REWARD/RISK
+
BREAKEVEN(S)
+
DTE
+
+
+ + +
+
Theoretical payoff at expiry based on avg cost. Does not account for time value or IV. Current spot shown as vertical line.
+
+
Closed / Booked Positions @@ -234,33 +259,6 @@
-
-
- Strategy Payoff at Expiry -
- - -
- -
-
-
-
NET PREMIUM
-
MAX PROFIT
-
MAX LOSS
-
REWARD/RISK
-
BREAKEVEN(S)
-
DTE
-
-
- - -
-
Theoretical payoff at expiry based on avg cost. Does not account for time value or IV. Current spot shown as vertical line.
-
-
Alert History
@@ -307,7 +305,7 @@ async function loadChart(h=8){ curH=h;['b2','b8','b24','b72'].forEach(id=>document.getElementById(id)?.classList.remove('on')); document.getElementById({2:'b2',8:'b8',24:'b24',72:'b72'}[h])?.classList.add('on'); const {summary,history}=await fetch('/api/pnl-history?hours='+h).then(r=>r.json()); - if(summary){const set=(id,v)=>{const e=document.getElementById(id);e.textContent=fmt(v);e.className='pval '+cls(v)};set('v-u',summary.totalUnrealised);set('v-r',summary.bookedPnl||0);set('v-t',summary.totalPnl);document.getElementById('s-pos').textContent=summary.openPositions;var bEl=document.getElementById('s-booked');if(bEl){bEl.textContent=fmt(summary.bookedPnl||0);bEl.className='sval '+cls(summary.bookedPnl||0);}var bEl=document.getElementById('s-booked');if(bEl){bEl.textContent=fmt(summary.bookedPnl||0);bEl.className='sval '+cls(summary.bookedPnl||0);}} + if(summary){const set=(id,v)=>{const e=document.getElementById(id);e.textContent=fmt(v);e.className='pval '+cls(v)};set('v-u',summary.totalUnrealised);set('v-r',summary.totalRealised||0);set('v-t',summary.totalPnl);document.getElementById('s-pos').textContent=summary.openPositions;var bEl=document.getElementById('s-booked');if(bEl){bEl.textContent=fmt(summary.totalRealised||0);bEl.className='sval '+cls(summary.totalRealised||0);}var bEl=document.getElementById('s-booked');if(bEl){bEl.textContent=fmt(summary.bookedPnl||0);bEl.className='sval '+cls(summary.bookedPnl||0);}} const canvas=document.getElementById('pnl-chart'),empty=document.getElementById('chart-empty'); if(!history||history.length<2){canvas.style.display='none';empty.classList.add('show');return;} canvas.style.display='block';empty.classList.remove('show'); @@ -566,7 +564,8 @@ async function loadPayoff() { var mktRes = await fetch('/api/market').then(function(r){return r.json();}).catch(function(){return {data:[]};}); var open = (posRes.data || []).filter(function(p){return p.is_closed===0;}); - var opts = open.filter(function(p){return /CE|PE/.test(p.tradingsymbol);}).map(function(p){ + var expFiltered=(_activeExpiry&&_activeExpiry!=='ALL')?open.filter(function(p){return expiryLabel(p.tradingsymbol)===_activeExpiry;}):open; + var opts = expFiltered.filter(function(p){return /CE|PE/.test(p.tradingsymbol);}).map(function(p){ p._parsed = parseOptionSym(p.tradingsymbol); return p; }).filter(function(p){return p._parsed !== null;}); @@ -760,6 +759,7 @@ function setExpiry(btn,exp){ if(row) row.querySelectorAll('.exp-tab').forEach(function(b){b.classList.remove('active');}); if(btn) btn.classList.add('active'); loadPositions(); + loadPayoff(); } loadConfig();refresh(); setInterval(refresh,60000);