Fix stats max profit/loss to use win/loss subsets only.

Corrects misleading breakdown rows and summary max amounts after trade log edits.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-30 22:28:46 +08:00
parent d324d30332
commit 2386eca324
2 changed files with 16 additions and 6 deletions
+12 -2
View File
@@ -64,16 +64,26 @@
}
function cellClass(key, val) {
if (key === 'max_loss' || key === 'max_profit') {
if (val === 0) return 'text-muted';
}
if (key === 'total_net' || key === 'max_profit' || key === 'avg_profit') {
if (val > 0) return 'text-profit';
if (val < 0) return 'text-loss';
}
if (key === 'max_loss' || key === 'avg_loss' || key === 'total_fee') {
return 'text-loss';
if (val < 0) return 'text-loss';
}
return '';
}
function fmtBreakdownVal(key, val) {
if ((key === 'max_loss' || key === 'max_profit') && (val === 0 || val === 0.0)) {
return '-';
}
return fmtNum(val);
}
function renderBreakdown(key) {
if (!cache || !cache.breakdowns) return;
var block = cache.breakdowns[key];
@@ -110,7 +120,7 @@
} else if (col.key === 'label') {
td.textContent = val || '-';
} else if (typeof val === 'number') {
td.textContent = fmtNum(val);
td.textContent = fmtBreakdownVal(col.key, val);
td.className = cellClass(col.key, val);
} else {
td.textContent = val != null ? val : '-';