This commit is contained in:
aaron 2026-02-23 00:14:06 +08:00
parent 009fb3ea0d
commit 5a5ce5ada4

View File

@ -496,7 +496,19 @@
<table class="orders-table" v-else> <table class="orders-table" v-else>
<thead> <thead>
<tr> <tr v-if="currentTab === 'positions'">
<th>交易对</th>
<th>方向</th>
<th>持仓量</th>
<th>入场价</th>
<th>标记价</th>
<th>杠杆</th>
<th>保证金</th>
<th>未实现盈亏</th>
<th>盈亏比例</th>
<th>强平价格</th>
</tr>
<tr v-else>
<th>交易对</th> <th>交易对</th>
<th>方向</th> <th>方向</th>
<th>等级</th> <th>等级</th>
@ -512,37 +524,63 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="order in displayOrders" :key="order.order_id"> <!-- 交易所持仓表格 -->
<td><strong>{{ order.symbol }}</strong></td> <template v-if="currentTab === 'positions'">
<td> <tr v-for="pos in displayOrders" :key="pos.id || pos.symbol">
<span class="side-badge" :class="'side-' + order.side"> <td><strong>{{ formatSymbol(pos.symbol) }}</strong></td>
{{ order.side === 'long' ? '做多' : '做空' }} <td>
</span> <span class="side-badge" :class="pos.side === 'long' ? 'side-long' : 'side-short'">
</td> {{ pos.side === 'long' ? '做多' : '做空' }}
<td> </span>
<span class="grade-badge" :class="'grade-' + (order.signal_grade || 'D')"> </td>
{{ order.signal_grade || 'D' }} <td>{{ pos.contracts || '0' }}</td>
</span> <td>${{ pos.entryPrice ? parseFloat(pos.entryPrice).toLocaleString() : '-' }}</td>
</td> <td>${{ pos.markPrice ? parseFloat(pos.markPrice).toLocaleString() : '-' }}</td>
<td>${{ order.entry_price ? order.entry_price.toLocaleString() : '-' }}</td> <td>{{ pos.leverage }}x</td>
<td>${{ order.current_price ? order.current_price.toLocaleString() : '-' }}</td> <td>${{ pos.initialMargin ? parseFloat(pos.initialMargin).toFixed(2) : '-' }}</td>
<td>${{ order.quantity ? order.quantity.toLocaleString() : '-' }}</td> <td :class="parseFloat(pos.unrealizedPnl || 0) >= 0 ? 'pnl-positive' : 'pnl-negative'">
<td>{{ order.leverage || 1 }}x</td> {{ parseFloat(pos.unrealizedPnl || 0) >= 0 ? '+' : '' }}${{ parseFloat(pos.unrealizedPnl || 0).toFixed(2) }}
<td>${{ order.stop_loss ? order.stop_loss.toLocaleString() : '-' }}</td> </td>
<td>${{ order.take_profit ? order.take_profit.toLocaleString() : '-' }}</td> <td :class="(pos.percentage || 0) >= 0 ? 'pnl-positive' : 'pnl-negative'">
<td> {{ (pos.percentage || 0).toFixed(2) }}%
<span v-if="order.pnl !== undefined" :class="order.pnl >= 0 ? 'pnl-positive' : 'pnl-negative'"> </td>
{{ order.pnl >= 0 ? '+' : '' }}${{ order.pnl.toFixed(2) }} <td>${{ pos.liquidationPrice ? parseFloat(pos.liquidationPrice).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) : '-' }}</td>
</span> </tr>
<span v-else>-</span> </template>
</td> <!-- 订单表格 -->
<td> <template v-else>
<span class="status-badge" :class="'status-' + order.status"> <tr v-for="order in displayOrders" :key="order.order_id">
{{ formatStatus(order.status) }} <td><strong>{{ order.symbol }}</strong></td>
</span> <td>
</td> <span class="side-badge" :class="'side-' + order.side">
<td>{{ formatTime(order.created_at) }}</td> {{ order.side === 'long' ? '做多' : '做空' }}
</tr> </span>
</td>
<td>
<span class="grade-badge" :class="'grade-' + (order.signal_grade || 'D')">
{{ order.signal_grade || 'D' }}
</span>
</td>
<td>${{ order.entry_price ? order.entry_price.toLocaleString() : '-' }}</td>
<td>${{ order.current_price ? order.current_price.toLocaleString() : '-' }}</td>
<td>${{ order.quantity ? order.quantity.toLocaleString() : '-' }}</td>
<td>{{ order.leverage || 1 }}x</td>
<td>${{ order.stop_loss ? order.stop_loss.toLocaleString() : '-' }}</td>
<td>${{ order.take_profit ? order.take_profit.toLocaleString() : '-' }}</td>
<td>
<span v-if="order.pnl !== undefined" :class="order.pnl >= 0 ? 'pnl-positive' : 'pnl-negative'">
{{ order.pnl >= 0 ? '+' : '' }}${{ order.pnl.toFixed(2) }}
</span>
<span v-else>-</span>
</td>
<td>
<span class="status-badge" :class="'status-' + order.status">
{{ formatStatus(order.status) }}
</span>
</td>
<td>{{ formatTime(order.created_at) }}</td>
</tr>
</template>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -692,6 +730,13 @@
'cancelled': '已取消' 'cancelled': '已取消'
}; };
return map[status] || status; return map[status] || status;
},
formatSymbol(symbol) {
// 将 CCXT 格式的交易对转换为简洁格式
// 例如BTC/USDT:USDT -> BTCUSDT
if (!symbol) return '-';
return symbol.replace('/', '').replace(':', '');
} }
}, },
mounted() { mounted() {