From bd0811e11386e983c719a7cc598b2129847d6895 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Sun, 15 Mar 2026 18:49:31 -0700 Subject: [PATCH] Fix: UI incorrectly marking break-even wins as losses --- app/paper/page.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/paper/page.js b/app/paper/page.js index 8693cf0..48e5578 100644 --- a/app/paper/page.js +++ b/app/paper/page.js @@ -79,7 +79,6 @@ export default function PaperDashboard() { return (
- {/* Header */}
@@ -105,10 +104,8 @@ export default function PaperDashboard() {
- {/* Market Card */} - {/* Strategy Tabs */}
{strategies.map(s => (
- {/* Worker Uptime */}
Worker: {formatUptime(data?.workerUptime)} @@ -211,7 +205,6 @@ function StrategyDetailView({ strategy, stats, trades }) { return (
- {/* Strategy Stats */}
@@ -228,7 +221,6 @@ function StrategyDetailView({ strategy, stats, trades }) {
- {/* Strategy Config */}
{strategy.config && Object.entries(strategy.config).map(([k, v]) => (
@@ -276,7 +268,6 @@ function StrategyDetailView({ strategy, stats, trades }) {
- {/* Open Positions */} {s.openPositions.length > 0 && (

Open Positions ({s.openPositions.length})

@@ -284,7 +275,6 @@ function StrategyDetailView({ strategy, stats, trades }) {
)} - {/* Trade History — only settled trades from DB */}

Trade History ({trades.length}) @@ -349,8 +339,11 @@ function StatBox({ label, value, color }) { } function TradeRow({ trade, isOpen }) { - const won = trade.pnl > 0; - const pnlColor = trade.pnl == null ? 'text-gray-400' : won ? 'text-green-600' : 'text-red-600'; + // Fix: Check side vs result for actual win condition, not strictly PNL > 0 + const won = trade.result && trade.side.toLowerCase() === trade.result.toLowerCase(); + const isNeutral = trade.result === 'cancelled' || trade.result === 'expired'; + + const pnlColor = trade.pnl == null ? 'text-gray-400' : trade.pnl > 0 ? 'text-green-600' : trade.pnl < 0 ? 'text-red-600' : 'text-gray-600'; return (
@@ -359,7 +352,7 @@ function TradeRow({ trade, isOpen }) { {isOpen ? ( ) : ( - {won ? '✅' : '❌'} + {isNeutral ? '➖' : won ? '✅' : '❌'} )} {trade.side} @ {trade.price}¢