or('計算損益時出錯:', e);
                }
            });
            
            // 格式化總損益
            const formattedProfit = totalProfit.toFixed(4);
            const profitClass = totalProfit > 0 ? 'text-success' : totalProfit < 0 ? 'text-danger' : '';
            $('#totalProfitDisplay').text(formattedProfit).removeClass('text-success text-danger').addClass(profitClass);
            
            // 計算勝率
            const winRate = (winCount / closedPositions.length * 100).