fix: wire booked PnL to UI stat card
This commit is contained in:
parent
4d1c956963
commit
ade11564a8
1 changed files with 1 additions and 1 deletions
|
|
@ -264,7 +264,7 @@ async function loadChart(h=8){
|
||||||
curH=h;['b2','b8','b24','b72'].forEach(id=>document.getElementById(id)?.classList.remove('on'));
|
curH=h;['b2','b8','b24','b72'].forEach(id=>document.getElementById(id)?.classList.remove('on'));
|
||||||
document.getElementById({2:'b2',8:'b8',24:'b24',72:'b72'}[h])?.classList.add('on');
|
document.getElementById({2:'b2',8:'b8',24:'b24',72:'b72'}[h])?.classList.add('on');
|
||||||
const {summary,history}=await fetch('/api/pnl-history?hours='+h).then(r=>r.json());
|
const {summary,history}=await fetch('/api/pnl-history?hours='+h).then(r=>r.json());
|
||||||
if(summary){const set=(id,v)=>{const e=document.getElementById(id);e.textContent=fmt(v);e.className='pval '+cls(v)};set('v-u',summary.totalUnrealised);set('v-r',summary.totalRealised);set('v-t',summary.totalPnl);document.getElementById('s-pos').textContent=summary.openPositions;}
|
if(summary){const set=(id,v)=>{const e=document.getElementById(id);e.textContent=fmt(v);e.className='pval '+cls(v)};set('v-u',summary.totalUnrealised);set('v-r',summary.totalRealised);set('v-t',summary.totalPnl);document.getElementById('s-pos').textContent=summary.openPositions;var bEl=document.getElementById('s-booked');if(bEl){bEl.textContent=fmt(summary.bookedPnl||0);bEl.className='sval '+cls(summary.bookedPnl||0);}}
|
||||||
const canvas=document.getElementById('pnl-chart'),empty=document.getElementById('chart-empty');
|
const canvas=document.getElementById('pnl-chart'),empty=document.getElementById('chart-empty');
|
||||||
if(!history||history.length<2){canvas.style.display='none';empty.classList.add('show');return;}
|
if(!history||history.length<2){canvas.style.display='none';empty.classList.add('show');return;}
|
||||||
canvas.style.display='block';empty.classList.remove('show');
|
canvas.style.display='block';empty.classList.remove('show');
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue