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 = () => {
} }
} }
// // /使ATR
const entryValue = trade.entry_value_usdt !== undefined const entryValue = trade.notional_usdt !== undefined && trade.notional_usdt !== null
? parseFloat(trade.entry_value_usdt) ? parseFloat(trade.notional_usdt)
: (quantity * entryPrice) : (
trade.entry_value_usdt !== undefined && trade.entry_value_usdt !== null
? parseFloat(trade.entry_value_usdt)
: (quantity * entryPrice)
)
const leverage = parseFloat(trade.leverage || 10) 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 const configSource = dashboardData?.trading_config || tradingConfig
@ -290,10 +296,6 @@ const StatsDashboard = () => {
} }
} }
//
const stopLossAmount = margin * stopLossPercentMargin
const takeProfitAmount = margin * takeProfitPercentMargin
// //
// 使 // 使
let stopLossPrice = 0 let stopLossPrice = 0
@ -304,6 +306,10 @@ const StatsDashboard = () => {
stopLossPrice = parseFloat(trade.stop_loss_price) stopLossPrice = parseFloat(trade.stop_loss_price)
takeProfitPrice = parseFloat(trade.take_profit_price) takeProfitPrice = parseFloat(trade.take_profit_price)
} else { } else {
//
const stopLossAmount = margin * stopLossPercentMargin
const takeProfitAmount = margin * takeProfitPercentMargin
// //
// = ( - ) × ( - ) × // = ( - ) × ( - ) ×
if (side === 'BUY') { if (side === 'BUY') {
@ -318,10 +324,24 @@ const StatsDashboard = () => {
takeProfitPrice = entryPrice - (takeProfitAmount / quantity) takeProfitPrice = entryPrice - (takeProfitAmount / quantity)
} }
} }
// // ATR /
const stopLossPercent = stopLossPercentMargin * 100 // let stopLossAmount = 0
const takeProfitPercent = takeProfitPercentMargin * 100 // 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' const stopLossPercentPrice = side === 'BUY'
@ -365,6 +385,7 @@ const StatsDashboard = () => {
</div> </div>
<div className="trade-info"> <div className="trade-info">
<div>数量: {parseFloat(trade.quantity || 0).toFixed(4)}</div> <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>保证金: {margin >= 0.01 ? margin.toFixed(2) : margin.toFixed(4)} USDT</div>
<div>入场价: {entryPrice.toFixed(4)}</div> <div>入场价: {entryPrice.toFixed(4)}</div>
@ -374,6 +395,9 @@ const StatsDashboard = () => {
{trade.leverage && ( {trade.leverage && (
<div>杠杆: {trade.leverage}x</div> <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'}`}> <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-price">(: {takeProfitPrice.toFixed(4)})</span>
<span className="take-amount">(金额: +{takeProfitAmount >= 0.01 ? takeProfitAmount.toFixed(2) : takeProfitAmount.toFixed(4)} USDT)</span> <span className="take-amount">(金额: +{takeProfitAmount >= 0.01 ? takeProfitAmount.toFixed(2) : takeProfitAmount.toFixed(4)} USDT)</span>
</div> </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>
<div className="trade-actions"> <div className="trade-actions">
<div className={`trade-pnl ${parseFloat(trade.pnl || 0) >= 0 ? 'positive' : 'negative'}`}> <div className={`trade-pnl ${parseFloat(trade.pnl || 0) >= 0 ? 'positive' : 'negative'}`}>