diff --git a/src/js/core/05d-calc-stats.js b/src/js/core/05d-calc-stats.js index e34038c..d0895b1 100644 --- a/src/js/core/05d-calc-stats.js +++ b/src/js/core/05d-calc-stats.js @@ -1,6 +1,6 @@ function calcPremiumStats(rows) { let totalPrem = 0, totalNotional = 0, totalCount = 0; - let otmCount = 0, itmCount = 0, openCount = 0; + let otmCount = 0, itmCount = 0, closedCount = 0, openCount = 0; let aprWeightedSum = 0, aprWeightTotal = 0; rows.forEach(r => { @@ -13,17 +13,19 @@ function calcPremiumStats(rows) { if (r.outcome === 'OPEN') { openCount++; } else if (r.outcome === 'EXPIRED') { otmCount++; } else if (r.outcome === 'ASSIGNED' || r.outcome === 'CALLED') { itmCount++; } + else if (r.outcome === 'CLOSED') { closedCount++; } if (r.annual != null) { aprWeightedSum += r.annual * notional; aprWeightTotal += notional; } }); - const settled = otmCount + itmCount; - const returnRate = settled > 0 ? otmCount / settled * 100 : null; + // CLOSED (buy-to-close) is a settled outcome: premium kept, no assignment/call-away. + const settled = otmCount + itmCount + closedCount; + const returnRate = settled > 0 ? (otmCount + closedCount) / settled * 100 : null; const portfolioAPR = aprWeightTotal > 0 ? aprWeightedSum / aprWeightTotal : null; - return { totalPrem, totalNotional, totalCount, otmCount, itmCount, openCount, settled, returnRate, portfolioAPR }; + return { totalPrem, totalNotional, totalCount, otmCount, itmCount, closedCount, openCount, settled, returnRate, portfolioAPR }; } if (typeof module !== 'undefined' && module.exports) { diff --git a/src/js/core/07-render-charts.js b/src/js/core/07-render-charts.js index 82cef2f..a5e9732 100644 --- a/src/js/core/07-render-charts.js +++ b/src/js/core/07-render-charts.js @@ -398,7 +398,7 @@ function rCharts(displayRows, lots) { 'Total Premium Collected', s.totalCount > 0 ? '$' + fmt(s.totalPrem) : dash, s.totalCount > 0 ? pos(s.settled) + ' settled' + (s.openCount > 0 ? ' · ' + s.openCount + ' open' : '') : '', - 'Sum of every option premium collected (gross of buy-to-close costs). Includes settled and open positions.') + + 'Sum of every option premium collected, net of buy-to-close costs. Includes settled and open positions.') + '