// History tab — closed trades, compact 2-line rows, period selector const HISTORY_TRADES = (() => { // Generate plausible trade history with relative dates const now = new Date(2026, 3, 27, 14, 30); // Apr 27, 2026 const mins = (n) => new Date(now.getTime() - n * 60000); const raw = [ // Today { sym: 'EURUSD', side: 'buy', vol: 0.50, openP: 1.07512, closeP: 1.07684, openT: mins(85), closeT: mins(40) }, { sym: 'XAUUSD', side: 'sell', vol: 0.10, openP: 2371.20, closeP: 2364.80, openT: mins(180), closeT: mins(120) }, { sym: 'GBPUSD', side: 'buy', vol: 0.30, openP: 1.26420, closeP: 1.26312, openT: mins(240), closeT: mins(200) }, { sym: 'BTCUSD', side: 'buy', vol: 0.05, openP: 66890, closeP: 67280, openT: mins(320), closeT: mins(60) }, { sym: 'NAS100', side: 'sell', vol: 0.50, openP: 18288, closeP: 18215, openT: mins(410), closeT: mins(150) }, // Yesterday { sym: 'USDJPY', side: 'sell', vol: 0.40, openP: 154.520, closeP: 154.180, openT: mins(60*22), closeT: mins(60*20) }, { sym: 'XAUUSD', side: 'buy', vol: 0.05, openP: 2362.10, closeP: 2358.40, openT: mins(60*24), closeT: mins(60*23) }, { sym: 'US500', side: 'buy', vol: 1.00, openP: 5172.0, closeP: 5184.5, openT: mins(60*26), closeT: mins(60*22) }, { sym: 'ETHUSD', side: 'sell', vol: 0.10, openP: 3540.20, closeP: 3508.10, openT: mins(60*30), closeT: mins(60*25) }, // This week { sym: 'AUDUSD', side: 'buy', vol: 0.50, openP: 0.65020, closeP: 0.65185, openT: mins(60*54), closeT: mins(60*50) }, { sym: 'USOIL', side: 'sell', vol: 0.20, openP: 79.40, closeP: 78.95, openT: mins(60*68), closeT: mins(60*64) }, { sym: 'GER40', side: 'buy', vol: 0.50, openP: 18594, closeP: 18642, openT: mins(60*72), closeT: mins(60*70) }, { sym: 'BTCUSD', side: 'sell', vol: 0.02, openP: 67950, closeP: 67500, openT: mins(60*84), closeT: mins(60*80) }, { sym: 'EURJPY', side: 'buy', vol: 0.30, openP: 166.120, closeP: 165.840, openT: mins(60*96), closeT: mins(60*92) }, { sym: 'XAGUSD', side: 'buy', vol: 0.20, openP: 30.842, closeP: 31.156, openT: mins(60*108),closeT: mins(60*100) }, // Last week / earlier { sym: 'GBPUSD', side: 'sell', vol: 0.50, openP: 1.26780, closeP: 1.26420, openT: mins(60*180),closeT: mins(60*175) }, { sym: 'NAS100', side: 'buy', vol: 0.20, openP: 18102, closeP: 18248, openT: mins(60*200),closeT: mins(60*195) }, { sym: 'XAUUSD', side: 'buy', vol: 0.10, openP: 2348.50, closeP: 2362.40, openT: mins(60*220),closeT: mins(60*215) }, { sym: 'SOLUSD', side: 'buy', vol: 1.00, openP: 162.40, closeP: 169.80, openT: mins(60*260),closeT: mins(60*255) }, { sym: 'USDCAD', side: 'sell', vol: 0.30, openP: 1.37580, closeP: 1.37120, openT: mins(60*300),closeT: mins(60*295) }, { sym: 'JP225', side: 'buy', vol: 0.50, openP: 38760, closeP: 38920, openT: mins(60*340),closeT: mins(60*335) }, { sym: 'NGAS', side: 'sell', vol: 0.50, openP: 2.912, closeP: 2.847, openT: mins(60*420),closeT: mins(60*410) }, ]; // Compute P&L using the same multipliers from data.jsx const mult = { 'XAUUSD': 100, 'XAGUSD': 5000, 'XPTUSD': 50, 'XPDUSD': 100, 'BTCUSD': 1, 'ETHUSD': 1, 'SOLUSD': 1, 'XRPUSD': 1, 'LTCUSD': 1, 'US500': 50, 'US30': 5, 'NAS100': 20, 'GER40': 25, 'UK100': 10, 'JP225': 5, 'USOIL': 1000, 'UKOIL': 1000, 'NGAS': 10000, }; return raw.map((tr, i) => { const m = mult[tr.sym] ?? 100000; const diff = tr.side === 'buy' ? (tr.closeP - tr.openP) : (tr.openP - tr.closeP); return { id: 'h' + i, ...tr, pl: diff * tr.vol * m, }; }); })(); // The period value is the code the filter compares against (`period === 'Today'` // below, and the cutoff map) — it stays English. The chip's label is looked up // from this map at RENDER time; a t() call out here would run before initI18n(). const HIST_PERIODS = ['Today', 'Week', 'Month', 'All']; const HIST_PERIOD_KEYS = { Today: 'history.period.today', Week: 'history.period.week', Month: 'history.period.month', All: 'history.period.all', }; function formatHistTime(d, now) { const diffMs = now - d; const diffH = diffMs / 3600000; const diffD = diffH / 24; if (diffH < 24 && d.getDate() === now.getDate()) { return fmtClock(d); // IO9: 24-hour, and 00:30 no longer prints as 24:30 } if (diffD < 2) return t('history.yesterday'); if (diffD < 7) return weekdayShort(d); return fmtMonthDay(d); } const HIST_CAT_COLOR = { FX: '#3B82F6', Metals: '#E0A21A', Energy: '#E2563B', Indices: '#8B5CF6', Crypto: '#F7931A' }; // MM/DD/YYYY HH:MM — one canonical timestamp in every locale (ID6). The whole // run is isolated so RTL text around it cannot reorder the date against the // time, and fmtClock supplies the hours (IO9). function fmtFullTS(d) { return bidiIsolate( d.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit', year: 'numeric' }) + ' ' + fmtClock(d)); } // One leg's execution list: "#dealId vol price" per line. function ExecColumn({ execs, inst, theme }) { if (!execs || !execs.length) { return