diff --git a/frontend/src/components/StatsDashboard.jsx b/frontend/src/components/StatsDashboard.jsx index 4a9322b..9dbb8dd 100644 --- a/frontend/src/components/StatsDashboard.jsx +++ b/frontend/src/components/StatsDashboard.jsx @@ -76,29 +76,22 @@ const StatsDashboard = () => { ? trade.entry_value_usdt : (parseFloat(trade.quantity || 0) * parseFloat(trade.entry_price || 0)) - // 格式化开仓时间 + // 计算保证金 = 开仓USDT数量 / 杠杆 + const leverage = parseFloat(trade.leverage || 1) + const margin = leverage > 0 ? entryValueUsdt / leverage : 0 + + // 格式化开仓时间为具体的年月日时分秒 const formatEntryTime = (timeStr) => { if (!timeStr) return null try { const date = new Date(timeStr) - const now = new Date() - const diffMs = now - date - const diffMins = Math.floor(diffMs / 60000) - const diffHours = Math.floor(diffMs / 3600000) - const diffDays = Math.floor(diffMs / 86400000) - - if (diffMins < 1) return '刚刚' - if (diffMins < 60) return `${diffMins}分钟前` - if (diffHours < 24) return `${diffHours}小时前` - if (diffDays < 7) return `${diffDays}天前` - - // 超过7天显示具体日期 - return date.toLocaleString('zh-CN', { - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit' - }) + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + const hours = String(date.getHours()).padStart(2, '0') + const minutes = String(date.getMinutes()).padStart(2, '0') + const seconds = String(date.getSeconds()).padStart(2, '0') + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` } catch (e) { return timeStr } @@ -111,7 +104,6 @@ const StatsDashboard = () => { {trade.side}
-
开仓金额: {entryValueUsdt.toFixed(2)} USDT
数量: {parseFloat(trade.quantity || 0).toFixed(4)}
入场价: {parseFloat(trade.entry_price || 0).toFixed(4)}
{trade.mark_price && ( @@ -120,6 +112,7 @@ const StatsDashboard = () => { {trade.leverage && (
杠杆: {trade.leverage}x
)} +
保证金: {margin.toFixed(2)} USDT
{trade.entry_time && (
开仓时间: {formatEntryTime(trade.entry_time)}
)}