@php use App\Support\SymbolPresentation; @endphp @extends('portal.layouts.master') @section('title', 'Trade History') @section('page-title', 'Trade History') @section('extra-css') /* ── Stat cards ── */ .hs-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; } @media (max-width: 1200px) { .hs-cards { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 700px) { .hs-cards { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 480px) { .hs-cards { grid-template-columns: 1fr; } } .hs-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem .6rem; display: flex; flex-direction: column; min-height: 108px; position: relative; overflow: hidden; } .hs-card::before { content: ''; position: absolute; inset: 0; background: var(--hc-grad, transparent); opacity: .18; pointer-events: none; border-radius: 10px; } .hs-card--blue { --hc-grad: linear-gradient(135deg,#3b82f6,transparent 65%); } .hs-card--green { --hc-grad: linear-gradient(135deg,#0ecb81,transparent 65%); } .hs-card--red { --hc-grad: linear-gradient(135deg,#f6465d,transparent 65%); } .hs-card--purple { --hc-grad: linear-gradient(135deg,#8b5cf6,transparent 65%); } .hs-card--amber { --hc-grad: linear-gradient(135deg,#f59e0b,transparent 65%); } .hs-card--cyan { --hc-grad: linear-gradient(135deg,#06b6d4,transparent 65%); } .hs-card .hc-label { font-size: .6rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: .25rem; } .hs-card .hc-value { font-size: 1.65rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: var(--text-primary); margin-bottom: auto; } .hs-card--green .hc-value { color: #0ecb81; } .hs-card--red .hc-value { color: #f6465d; } .hs-card--amber .hc-value { color: #f59e0b; } .hs-card--purple .hc-value { color: #a78bfa; } .hs-card--cyan .hc-value { color: #22d3ee; } .hc-chart { margin-top: .5rem; height: 38px; overflow: hidden; } .hc-chart svg { width: 100%; height: 100%; display: block; } /* donut gauge */ .hc-gauge { display: flex; align-items: center; justify-content: flex-end; margin-top: .3rem; } .hc-gauge svg { width: 52px; height: 52px; } .hc-gauge-track { fill: none; stroke: rgba(245,158,11,.2); stroke-width: 6; } .hc-gauge-fill { fill: none; stroke: #f59e0b; stroke-width: 6; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; } .hc-gauge-num { font-size: .85rem; font-weight: 800; fill: #f59e0b; } /* ── Filters ── */ .hs-filters { display: flex; gap: .65rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; } .hs-filters .form-select, .hs-filters .form-control { background: var(--bg-card) !important; border-color: var(--border) !important; color: var(--text-primary) !important; font-size: .82rem; padding: .4rem .7rem; border-radius: 7px; min-width: 0; } .hs-filters .form-select { max-width: 160px; } .hs-filters .form-control { max-width: 150px; } .hs-filters .form-control::placeholder { color: var(--text-muted); } /* ── Table ── */ .hs-table-header { padding: .8rem 1rem; font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border); } .symbol-cell { display: flex; align-items: center; gap: .55rem; } .symbol-mini-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; font-size: .82rem; overflow: hidden; flex-shrink: 0; } .symbol-mini-icon img { width: 16px; height: 16px; object-fit: contain; border-radius: 50%; } .badge-filled { display: inline-block; padding: .18rem .55rem; border-radius: 4px; font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: rgba(14,203,129,.15); color: #0ecb81; border: 1px solid rgba(14,203,129,.25); } .badge-buy { display: inline-block; padding: .22rem .6rem; border-radius: 5px; font-size: .7rem; font-weight: 700; background: rgba(14,203,129,.15); color: #0ecb81; border: 1px solid rgba(14,203,129,.25); } .badge-sell { display: inline-block; padding: .22rem .6rem; border-radius: 5px; font-size: .7rem; font-weight: 700; background: rgba(246,70,93,.15); color: #f6465d; border: 1px solid rgba(246,70,93,.25); } .badge-call, .badge-put, .badge-binary-status { display: inline-block; padding: .22rem .55rem; border-radius: 5px; font-size: .68rem; font-weight: 750; text-transform: uppercase; } .badge-call { color: #0ecb81; background: rgba(14,203,129,.14); border: 1px solid rgba(14,203,129,.24); } .badge-put { color: #f6465d; background: rgba(246,70,93,.14); border: 1px solid rgba(246,70,93,.24); } .badge-binary-status.open { color: #3b82f6; background: rgba(59,130,246,.13); } .badge-binary-status.won { color: #0ecb81; background: rgba(14,203,129,.13); } .badge-binary-status.lost { color: #f6465d; background: rgba(246,70,93,.13); } .badge-binary-status.cancelled { color: var(--text-muted); background: rgba(132,142,156,.13); } .badge-binary-status.manually_settled { color: #f59e0b; background: rgba(245,158,11,.13); } .hs-history-section + .hs-history-section { margin-top: 1rem; } .hs-history-note { margin: -.25rem 0 1rem; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 8px; background: rgba(59,130,246,.06); color: var(--text-secondary); font-size: .78rem; line-height: 1.5; } .hs-tabs { display:flex; gap:.45rem; flex-wrap:wrap; margin:0 0 1rem; padding:.3rem; border:1px solid var(--border); border-radius:10px; background:var(--bg-card); } .hs-tab { border:1px solid transparent; border-radius:7px; padding:.55rem .85rem; background:transparent; color:var(--text-secondary); font-size:.78rem; font-weight:700; cursor:pointer; transition:all .15s ease; } .hs-tab:hover { color:var(--text-primary); background:rgba(59,130,246,.08); } .hs-tab.is-active { color:var(--text-primary); background:rgba(111,78,210,.28); border-color:rgba(139,92,246,.55); } .hs-history-pane { display:none; } .hs-history-pane.is-active { display:block; } @endsection @section('content') @php $gaugeR = 20; $gaugeCircum = 2 * M_PI * $gaugeR; $gaugeDash = $openPositions > 0 ? $gaugeCircum * 0.72 : 0; @endphp {{-- Stat cards --}}
{{-- 1. Total Trades --}}
Total Trades
{{ $totalTrades }}
{{-- 2. Total Buys --}}
Total Buys
{{ $buyCount }}
{{-- 3. Total Sells --}}
Total Sells
{{ $sellCount }}
@if($sellCount > 0) @else {{-- flat line when no sells --}} @endif
{{-- 4. Binary Options --}}
Binary Options
{{ $binaryCount }}
@if($binaryCount > 0) @else @endif
{{-- 5. Total Volume --}}
Total Volume
${{ number_format($totalVolume, 2) }}
@php $vbars = [6,10,8,14,10,18,14,20,16,24,18,28,20,26,22,30,24,28,26,32]; @endphp @foreach($vbars as $vi => $vh) @endforeach
{{-- 6. Open Positions --}}
Open Positions
{{ $openPositions }}
{{ $openPositions }}
{{-- Filters --}}
@if(request()->hasAny(['symbol_id','side','product','from','to'])) Clear @endif
How to read this history: Market order means the trade was executed immediately at the current market quote. Entry price is the opening price; close price is the closing price; realized P&L is the result after closing.
@php $historyTab = in_array($product, ['asset', 'leveraged', 'binary', 'prediction'], true) ? $product : 'all'; @endphp
All Trades
@include('shared.trade-history-timeline', ['history' => $allHistory, 'dark' => true])
Prediction Market History
@include('shared.trade-history-timeline', ['history' => $predictionHistory, 'dark' => true])
{{-- Trades table --}}
Market Trade History
@if($trades->isEmpty())
No trades found.
@else
@foreach($trades as $trade) @php [$icn, $icColor] = SymbolPresentation::baseIconPair($trade->symbol); $icIsImg = str_starts_with($icn, 'img:'); $pair = SymbolPresentation::pairLabel($trade->symbol); @endphp @php $realizedPnl = $trade->side === 'sell' && $trade->realized_pnl !== null ? (float) $trade->realized_pnl : null; @endphp @endforeach
Time Type Instrument Order type Execution price Quantity Fee USD value Status P&L
{{ $trade->traded_at->format('M j, Y H:i:s') }} {{ strtoupper($trade->side) }}
@if($icIsImg) {{ strtoupper(substr($trade->symbol->name??'?',0,2)) }} @elseif($icn) @else {{ strtoupper(substr($trade->symbol->name??'?',0,2)) }} @endif
{{ $pair }}
Market order {{ $trade->side === 'buy' ? 'Entry' : 'Close' }}
{{ number_format($trade->price, $trade->symbol->decimal_places ?? 2) }}
{{ rtrim(rtrim(number_format((float) $trade->quantity, 8), '0'), '.') }} USD {{ number_format((float) $trade->fee, 2) }} {{ $trade->currency ?: 'USD' }} {{ number_format($trade->total_cost, 2) }} Filled @if($realizedPnl === null) — @else {{ $realizedPnl > 0 ? '+' : ($realizedPnl < 0 ? '-' : '') }}{{ $trade->currency }} {{ number_format(abs($realizedPnl), 2) }} @endif
@if($trades->hasPages())
{{ $trades->withQueryString()->links('pagination::bootstrap-5') }}
@endif @endif
{{-- Leveraged-position history --}}
Leveraged Trading History{{ $leveragedCount }} position{{ $leveragedCount === 1 ? '' : 's' }}
@if($leveragedHistory->isEmpty())
No leveraged positions found.
@else
@foreach($leveragedHistory as $position) @php [$licon, $lcolor] = SymbolPresentation::baseIconPair($position->symbol); $ldecimals = $position->symbol->decimal_places ?? 2; @endphp @endforeach
OpenedClosedInstrumentDirectionLeverageMarginExposureEntry priceClose priceExit reasonStatusRealized P&L
{{ optional($position->opened_at)->format('M j, Y H:i:s') ?: '—' }} {{ optional($position->closed_at)->format('M j, Y H:i:s') ?: '—' }}
{{ $position->symbol->name ?? 'Unknown asset' }}
{{ strtoupper($position->direction) }} {{ $position->leverage }}× USD {{ number_format($position->margin, 2) }} USD {{ number_format($position->exposure, 2) }} {{ number_format($position->entry_price, $ldecimals) }} {{ $position->close_price !== null ? number_format($position->close_price, $ldecimals) : '—' }} {{ ['manual' => 'Manual close', 'stop_loss' => 'Stop Loss', 'take_profit' => 'Take Profit', 'liquidation' => 'Liquidated', 'liquidated' => 'Liquidated'][$position->close_reason] ?? ucfirst(str_replace('_', ' ', $position->close_reason ?: '—')) }} {{ ucfirst($position->status) }} {{ $position->realized_pnl === null ? '—' : (($position->realized_pnl >= 0 ? '+' : '-') . 'USD ' . number_format(abs($position->realized_pnl), 2)) }}
@if($leveragedHistory->hasPages())
{{ $leveragedHistory->withQueryString()->links('pagination::bootstrap-5') }}
@endif @endif
{{-- Binary-options history is a separate data source from standard market trades. --}}
Binary Options History {{ $binaryOptions->total() }} trade{{ $binaryOptions->total() === 1 ? '' : 's' }}
@if($binaryOptions->isEmpty())
No binary-option trades found.
@else
@foreach($binaryOptions as $option) @php [$binaryIcon, $binaryColor] = SymbolPresentation::baseIconPair($option->symbol); $binaryIconIsImg = str_starts_with($binaryIcon, 'img:'); $binaryDecimals = ($option->symbol->decimal_places ?? 2); $binaryPnl = $option->status === 'won' || ($option->status === 'manually_settled' && (float) $option->profit > 0) ? (float) $option->profit : ($option->status === 'lost' ? -(float) $option->stake : null); @endphp @endforeach
Time Instrument Direction Stake Strike Close price Status P&L
{{ $option->created_at->format('M j, Y H:i:s') }}
@if($binaryIconIsImg) {{ strtoupper(substr($option->symbol->name ?? '?',0,2)) }} @elseif($binaryIcon) @else {{ strtoupper(substr($option->symbol->name ?? '?',0,2)) }} @endif
{{ $option->symbol->name ?? 'Unknown asset' }}
{{ strtoupper($option->direction) }} {{ $option->currency }} {{ number_format($option->stake, 2) }} {{ number_format($option->strike_price, $binaryDecimals) }} {{ $option->close_price !== null ? number_format($option->close_price, $binaryDecimals) : '—' }} {{ str_replace('_', ' ', $option->status) }} @if($binaryPnl === null) — @else {{ $binaryPnl >= 0 ? '+' : '-' }}{{ $option->currency }} {{ number_format(abs($binaryPnl), 2) }} @endif
@if($binaryOptions->hasPages())
{{ $binaryOptions->withQueryString()->links('pagination::bootstrap-5') }}
@endif @endif
@push('scripts') @endpush @endsection