This commit is contained in:
薇薇安 2026-01-18 20:02:26 +08:00
parent 69145c4345
commit 2c6a239973

View File

@ -250,12 +250,18 @@ const StatsDashboard = () => {
}
}
//
const entryValue = trade.entry_value_usdt !== undefined
// /使ATR
const entryValue = trade.notional_usdt !== undefined && trade.notional_usdt !== null
? parseFloat(trade.notional_usdt)
: (
trade.entry_value_usdt !== undefined && trade.entry_value_usdt !== null
? parseFloat(trade.entry_value_usdt)
: (quantity * entryPrice)
)
const leverage = parseFloat(trade.leverage || 10)
const margin = leverage > 0 ? entryValue / leverage : entryValue
const margin = trade.margin_usdt !== undefined && trade.margin_usdt !== null
? parseFloat(trade.margin_usdt)
: (leverage > 0 ? entryValue / leverage : entryValue)
//
const configSource = dashboardData?.trading_config || tradingConfig
@ -290,10 +296,6 @@ const StatsDashboard = () => {
}
}
//
const stopLossAmount = margin * stopLossPercentMargin
const takeProfitAmount = margin * takeProfitPercentMargin
//
// 使
let stopLossPrice = 0
@ -304,6 +306,10 @@ const StatsDashboard = () => {
stopLossPrice = parseFloat(trade.stop_loss_price)
takeProfitPrice = parseFloat(trade.take_profit_price)
} else {
//
const stopLossAmount = margin * stopLossPercentMargin
const takeProfitAmount = margin * takeProfitPercentMargin
//
// = ( - ) × ( - ) ×
if (side === 'BUY') {
@ -319,9 +325,23 @@ const StatsDashboard = () => {
}
}
//
const stopLossPercent = stopLossPercentMargin * 100 //
const takeProfitPercent = takeProfitPercentMargin * 100 //
// ATR /
let stopLossAmount = 0
let takeProfitAmount = 0
if (entryPrice > 0 && quantity > 0 && stopLossPrice > 0 && takeProfitPrice > 0) {
if (side === 'BUY') {
stopLossAmount = Math.max(0, (entryPrice - stopLossPrice) * quantity)
takeProfitAmount = Math.max(0, (takeProfitPrice - entryPrice) * quantity)
} else {
stopLossAmount = Math.max(0, (stopLossPrice - entryPrice) * quantity)
takeProfitAmount = Math.max(0, (entryPrice - takeProfitPrice) * quantity)
}
} else {
stopLossAmount = margin * stopLossPercentMargin
takeProfitAmount = margin * takeProfitPercentMargin
}
const stopLossPercent = margin > 0 ? (stopLossAmount / margin) * 100 : (stopLossPercentMargin * 100)
const takeProfitPercent = margin > 0 ? (takeProfitAmount / margin) * 100 : (takeProfitPercentMargin * 100)
//
const stopLossPercentPrice = side === 'BUY'
@ -365,6 +385,7 @@ const StatsDashboard = () => {
</div>
<div className="trade-info">
<div>数量: {parseFloat(trade.quantity || 0).toFixed(4)}</div>
<div>名义: {entryValue >= 0.01 ? entryValue.toFixed(2) : entryValue.toFixed(4)} USDT</div>
<div>保证金: {margin >= 0.01 ? margin.toFixed(2) : margin.toFixed(4)} USDT</div>
<div>入场价: {entryPrice.toFixed(4)}</div>
@ -374,6 +395,9 @@ const StatsDashboard = () => {
{trade.leverage && (
<div>杠杆: {trade.leverage}x</div>
)}
{trade.atr !== undefined && trade.atr !== null && (
<div>ATR: {parseFloat(trade.atr).toFixed(6)}</div>
)}
{/* 价格涨跌比例 */}
<div className={`price-change ${priceChangePercent >= 0 ? 'positive' : 'negative'}`}>
@ -400,6 +424,16 @@ const StatsDashboard = () => {
<span className="take-price">(: {takeProfitPrice.toFixed(4)})</span>
<span className="take-amount">(金额: +{takeProfitAmount >= 0.01 ? takeProfitAmount.toFixed(2) : takeProfitAmount.toFixed(4)} USDT)</span>
</div>
{(trade.take_profit_1 || trade.take_profit_2) && (
<div style={{ marginTop: '6px', fontSize: '12px', color: '#666' }}>
{trade.take_profit_1 && (
<span style={{ marginRight: '10px' }}>TP1: {parseFloat(trade.take_profit_1).toFixed(4)}</span>
)}
{trade.take_profit_2 && (
<span>TP2: {parseFloat(trade.take_profit_2).toFixed(4)}</span>
)}
</div>
)}
</div>
<div className="trade-actions">
<div className={`trade-pnl ${parseFloat(trade.pnl || 0) >= 0 ? 'positive' : 'negative'}`}>