Initial working version, positions show.

This commit is contained in:
2026-04-01 19:17:09 -05:00
commit 28afa137cb
7 changed files with 398 additions and 0 deletions

32
frontend/app.js Normal file
View File

@@ -0,0 +1,32 @@
// 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 = `<td>${p.symbol}</td><td>${p.position}</td><td>${avg}</td><td>${p.account ?? ''}</td>`;
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);