INNER CODE UNIT · JavaScript
pages
pamgarcia1993/robinhood-lp-bot · legacy/bot.js:241
const pages = Math.max(1, Math.ceil(all.length / LEDGER_PER_PAGE));
page = Math.min(Math.max(0, page), pages - 1);
const slice = all.slice(page * LEDGER_PER_PAGE, page * LEDGER_PER_PAGE + LEDGER_PER_PAGE);
const sg = (n, d) => (n >= 0 ? "+" : "") + n.toFixed(d);
const money = (v) => (v >= 0 ? "+" : "-") + "$" + Math.abs(v).toFixed(2);
const when = (ts) => ts ? new Date(ts).toLocaleString("id-ID", { day: "2-digit", month: "short", hour: "2-digit", minute: "2-digit" }) : "?";
const T = [];
slice.forEach((e, i) => {
const n = page * LEDGER_PER_PAGE + i + 1;
if (i) T.push("");
const win = e.pnlEth == null ? "⬜" : (e.pnlEth >= 0 ? "🟩" : "🟥");
T.push(`${win} ${tokenEmoji(e.sym)} ${e.sym}${e.mode === "inrange" ? " 🎯" : ""} ${n}/${all.length}`);
T.push(` ${when(e.closedAt)} · hold ${CH.fmtAge(e.heldMs)}`);
T.push(` ${padR("modal", 6)} ${padL((e.depEth ?? 0).toFixed(6) + "Ξ", 11)}`);
T.push(` ${padR("balik", 6)} ${padL((e.outEth ?? 0).toFixed(6) + "Ξ", 11)}`);
if (e.pnlEth != null) {
T.push(` ${padR("PnL", 6)} ${padL(sg(e.pnlEth, 6) + "Ξ", 11)} ${padL(e.pnlUsd != null ? money(e.pnlUsd) : "—", 9)} ${sg(e.pnlPct ?? 0, 1)}%`);