Jimin Huang commited on
Commit
953e8bb
Β·
1 Parent(s): 70deb70

Change settings

Browse files
Files changed (1) hide show
  1. src/views/LiveView.vue +17 -2
src/views/LiveView.vue CHANGED
@@ -225,11 +225,26 @@ onBeforeUnmount(() => {
225
  })
226
 
227
  /* ---------- helpers ---------- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  const fmtUSD = (n) => (n ?? 0).toLocaleString(undefined, { style: 'currency', currency: 'USD', maximumFractionDigits: 2 })
229
  const signedMoney = (n) => `${n >= 0 ? '+' : 'βˆ’'}${fmtUSD(Math.abs(n))}`
230
- const signedPct = (p) => (p == null ? 'β€”' : `${(p >= 0 ? '+' : 'βˆ’')}${Math.abs(p * 100).toFixed(2)}%`)
231
  const fmtSharpe = (s) => (s == null ? 'β€”' : Number(s).toFixed(2))
232
- const fmtRate = (r) => (r == null ? 'β€”' : `${(r * 100).toFixed(0)}%`)
233
  const score = (row) => (typeof row.balance === 'number' ? row.balance : -Infinity)
234
  const profitOf = (c) => (typeof c?.profitUsd === 'number' ? c.profitUsd : ((c?.balance ?? 0) - 100000))
235
 
 
225
  })
226
 
227
  /* ---------- helpers ---------- */
228
+ const asRatio = (x) => {
229
+ if (x == null || Number.isNaN(x)) return null;
230
+ // if |x| > 1.2 we assume it's already a % number (e.g., 58 or -79.23), convert to ratio
231
+ return Math.abs(x) > 5 ? (x / 100) : x;
232
+ };
233
+ const signedPct = (p) => {
234
+ const r = asRatio(p);
235
+ if (r == null) return 'β€”';
236
+ const sign = r >= 0 ? '+' : 'βˆ’';
237
+ return `${sign}${(Math.abs(r) * 100).toFixed(2)}%`;
238
+ };
239
+
240
+ const fmtRate = (r) => {
241
+ const rr = asRatio(r);
242
+ if (rr == null) return 'β€”';
243
+ return `${(rr * 100).toFixed(0)}%`;
244
+ };
245
  const fmtUSD = (n) => (n ?? 0).toLocaleString(undefined, { style: 'currency', currency: 'USD', maximumFractionDigits: 2 })
246
  const signedMoney = (n) => `${n >= 0 ? '+' : 'βˆ’'}${fmtUSD(Math.abs(n))}`
 
247
  const fmtSharpe = (s) => (s == null ? 'β€”' : Number(s).toFixed(2))
 
248
  const score = (row) => (typeof row.balance === 'number' ? row.balance : -Infinity)
249
  const profitOf = (c) => (typeof c?.profitUsd === 'number' ? c.profitUsd : ((c?.balance ?? 0) - 100000))
250