diff --git a/src/js/core/06-render-table.js b/src/js/core/06-render-table.js index 328605e..7ae667e 100644 --- a/src/js/core/06-render-table.js +++ b/src/js/core/06-render-table.js @@ -166,8 +166,12 @@ function _openRow(r) { // "↻ rolled" tag on a CLOSED leg that was rolled into a new option (Wheeler // roll: the replacement carries rolledFrom = this id). Derived, so deleting the // replacement drops the tag. +function _isRolled(r) { + return r.outcome === 'CLOSED' && trades.some(t => t.rolledFrom === r.id); +} + function _rolledTag(r) { - if (r.outcome !== 'CLOSED' || !trades.some(t => t.rolledFrom === r.id)) return ''; + if (!_isRolled(r)) return ''; return '\u21bb rolled'; } @@ -175,13 +179,22 @@ function _rolledTag(r) { // collected premium you kept by closing early. Hidden when there is no premium // to capture. Graded green/orange/red by how much was kept. function _captureBadge(r) { - if (r.outcome !== 'CLOSED') return ''; + if (r.outcome !== 'CLOSED' || _isRolled(r)) return ''; const pct = capturePct(r.premium, r.closeCost); if (pct === null) return ''; const col = pct >= 70 ? 'var(--green)' : pct >= 40 ? 'var(--orange)' : 'var(--red)'; return '' + Math.round(pct) + '% kept'; } +// Net premium of a CLOSED leg (premium − closeCost). A buy-back above the +// premium (common on a roll) goes negative: show "−$X" in red, not "+$-X". +function _netPremHtml(r) { + const net = r.premium - (r.closeCost || 0); + return net < 0 + ? '\u2212$' + fmt(-net) + '' + : '+$' + fmt(net); +} + // "days early" tag for a buy-to-close — days still on the clock at close // (expiry − closeDate). Completes the close-vs-hold story next to % kept. function _daysEarlyTag(r) { @@ -211,7 +224,7 @@ function _histRow(r) { + '