mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-02 10:31:04 +08:00
**Problem:** Competition page shows "NaN%" for gap difference when trader P&L percentages are null/undefined. **Root Cause:** Line 227: `const gap = trader.total_pnl_pct - opponent.total_pnl_pct` - If either value is `undefined` or `null`, result is `NaN` - Display shows "领先 NaN%" or "落后 NaN%" **Solution:** Add null coalescing to default undefined/null values to 0: ```typescript const gap = (trader.total_pnl_pct ?? 0) - (opponent.total_pnl_pct ?? 0) ``` **Impact:** - ✅ Gap calculation returns 0 when data is missing (shows 0.00%) - ✅ Prevents confusing "NaN%" display - ✅ Graceful degradation for incomplete data Fixes #633 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
4f2177a0a0
commit
8db6dc3b06
@@ -392,7 +392,7 @@ export function CompetitionPage() {
|
||||
{sortedTraders.map((trader, index) => {
|
||||
const isWinning = index === 0
|
||||
const opponent = sortedTraders[1 - index]
|
||||
const gap = trader.total_pnl_pct - opponent.total_pnl_pct
|
||||
const gap = (trader.total_pnl_pct ?? 0) - (opponent.total_pnl_pct ?? 0)
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user