/* ═══════════════════════════════════════════════════════════════
JOURNAL screen — trade timeline + stats
═══════════════════════════════════════════════════════════════ */
function JournalScreen() {
const store = window.useStore ? window.useStore() : (window.MOCK || {});
const JOURNAL = Array.isArray(store.JOURNAL) ? store.JOURNAL : [];
const wins = JOURNAL.filter(j => j && j.result === "win");
const losses = JOURNAL.filter(j => j && j.result === "loss");
const totalPnl = JOURNAL.reduce((acc, j) => acc + (Number(j && j.pnlEur) || 0), 0);
const pnlPct = isFinite(totalPnl) ? (totalPnl / 10000) * 100 : 0;
return (
Journal
Historique des trades · {JOURNAL.length} entrées · 30 derniers jours
} />
{wins.length + losses.length > 0 ? ((wins.length / (wins.length+losses.length))*100).toFixed(0) : 0}%
{wins.length}W · {losses.length}L
}
/>
{(() => {
// Best pair par PnL cumulé
const byPair = {};
JOURNAL.forEach(j => { if (j && j.pair) byPair[j.pair] = (byPair[j.pair] || 0) + (j.pnlEur || 0); });
const bestPair = Object.entries(byPair).sort((a,b)=>b[1]-a[1])[0];
return (
{bestPair ? bestPair[0] : "—"}
=0 ? "bull":"bear"}`} style={{ fontSize:11 }}>{bestPair ? (bestPair[1]>=0?"+":"")+bestPair[1].toFixed(2)+"€" : "—"}
}
/>
);
})()}
{JOURNAL.length}
{JOURNAL.filter(j=>j.result==="open").length} open
}
/>
{["Tous","Wins","Losses","Open","LONG","SHORT"].map((t,i) => (
{t}
))}
{JOURNAL.length === 0 ? (
Aucun trade dans le journal
L'historique apparaîtra ici dès qu'un trade sera clôturé.
) : (
JOURNAL.map(j => j &&
)
)}
);
}
function StatBlock({ label, value }) {
return (
);
}
function JournalCard({ entry }) {
if (!entry) return null;
const isOpen = entry.result === "open";
const isWin = entry.result === "win";
const resultColor = isOpen ? "var(--info)" : isWin ? "var(--bull)" : "var(--bear)";
const pnlEur = Number(entry.pnlEur) || 0;
const pnlPct = Number(entry.pnlPct) || 0;
const direction = entry.direction || "LONG";
return (
{((entry.date || "").split("·")[1] || "").trim() || "—"}
{((entry.date || "").split("·")[0] || "").trim() || "—"}
{entry.pair}/USDT
{isOpen ? "OPEN" : isWin ? "WIN" : "LOSS"}
{entry.duration}
{entry.scoreIn ? (<>
·
Score entrée {entry.scoreIn}
{entry.scoreOut && entry.scoreOut !== entry.scoreIn && (
<>
sortie {entry.scoreOut}
>
)}
>) : null}
= 0 ? "var(--bull)":"var(--bear)" }}>
{pnlEur >= 0 ? "+":"−"}€{Math.abs(pnlEur).toFixed(2)}
= 0 ? "var(--bull)":"var(--bear)", opacity:0.75 }}>
{fmtPct(pnlPct)}
{entry.notes &&
{entry.notes}
}
{(entry.tags && entry.tags.length > 0) && (
{entry.tags.map(t => {t})}
)}
);
}
function JTick({ label, value, color }) {
return (
{label}
{value ? fmtNum(value) : "—"}
);
}
Object.assign(window, { JournalScreen });