// Minimal vanilla-JS frontend to poll only positions and render the positions table const qs = (s) => document.querySelector(s); const ptbody = qs('#positions-table tbody'); async function fetchJson(path) { const res = await fetch(path); if (!res.ok) throw new Error('Network response not ok'); return res.json(); } function renderPositions(list) { ptbody.innerHTML = ''; for (const p of list) { const row = document.createElement('tr'); const avg = p.averageCost ?? p.average_cost ?? ''; row.innerHTML = `${p.symbol}${p.position}${avg}${p.account ?? ''}`; ptbody.appendChild(row); } } async function pollPositions() { try { const positions = await fetchJson('/api/positions'); renderPositions(positions); } catch (e) { console.warn('Positions polling error', e); } } // start polling every 2 seconds pollPositions(); setInterval(pollPositions, 2000);