194 lines
6.5 KiB
HTML
194 lines
6.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<title>Financial Dashboard</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--header-bg: #4a5568;
|
|
--text-up: #28a745;
|
|
--text-down: #dc3545;
|
|
}
|
|
|
|
body {
|
|
background-color: #f4f7f6;
|
|
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto;
|
|
margin: 0;
|
|
padding: 10px;
|
|
}
|
|
|
|
.card {
|
|
border: none;
|
|
border-radius: 12px;
|
|
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-header {
|
|
background-color: white !important;
|
|
border-bottom: 1px solid #eee;
|
|
padding: 15px;
|
|
}
|
|
|
|
/* Zebra Striping Logic */
|
|
.table-striped tbody tr:nth-of-type(odd) {
|
|
background-color: rgba(0, 0, 0, 0.03);
|
|
}
|
|
|
|
/* Sticky Column for Mobile Scrolling */
|
|
.table-responsive { border-radius: 8px; }
|
|
|
|
.table thead th {
|
|
background-color: var(--header-bg) !important;
|
|
color: white !important;
|
|
font-size: 0.7rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
text-align: center;
|
|
white-space: nowrap;
|
|
padding: 12px 8px;
|
|
border: none;
|
|
}
|
|
|
|
.table td {
|
|
text-align: center;
|
|
vertical-align: middle;
|
|
font-size: 0.85rem;
|
|
white-space: nowrap;
|
|
border-color: #f1f1f1;
|
|
}
|
|
|
|
/* Keep Instrument Name fixed on the left while swiping */
|
|
.table td:first-child, .table th:first-child {
|
|
position: sticky;
|
|
left: 0;
|
|
z-index: 10;
|
|
text-align: left;
|
|
min-width: 140px;
|
|
background-color: white;
|
|
font-weight: 700;
|
|
}
|
|
|
|
/* Ensure zebra stripe works on sticky column */
|
|
.table-striped tbody tr:nth-of-type(odd) td:first-child {
|
|
background-color: #f9f9f9;
|
|
}
|
|
|
|
/* Custom UI Elements */
|
|
.btn-refresh {
|
|
background-color: #0d6efd;
|
|
color: white !important;
|
|
font-weight: 600;
|
|
border-radius: 6px;
|
|
padding: 6px 16px;
|
|
transition: 0.2s;
|
|
}
|
|
|
|
.text-up { color: var(--text-up); font-weight: 600; }
|
|
.text-down { color: var(--text-down); font-weight: 600; }
|
|
|
|
.badge-kd {
|
|
background-color: #6c757d;
|
|
font-size: 0.75rem;
|
|
padding: 5px 8px;
|
|
}
|
|
|
|
#loading { display: none; margin-left: 10px; font-size: 0.8rem; color: #666; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container-fluid p-0">
|
|
<div class="card">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0 text-dark">Portfolio Signals</h5>
|
|
<div>
|
|
<span id="loading">Updating...</span>
|
|
<button class="btn btn-refresh btn-sm" onclick="loadData()">Refresh</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover table-striped mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th>Instrument</th>
|
|
<th>Close</th>
|
|
<th>Chg%</th>
|
|
<th>52W Range</th>
|
|
<th>v20 EMA</th>
|
|
<th>v50 EMA</th>
|
|
<th>v100 EMA</th>
|
|
<th>v200 EMA</th>
|
|
<th>K/D</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tableBody">
|
|
<tr><td colspan="9" class="p-4">Initializing data engine...</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function loadData() {
|
|
const loading = document.getElementById('loading');
|
|
const tbody = document.getElementById('tableBody');
|
|
|
|
loading.style.display = 'inline';
|
|
|
|
try {
|
|
const response = await fetch('/api/summary');
|
|
const data = await response.json();
|
|
|
|
tbody.innerHTML = '';
|
|
|
|
if (data.length === 0) {
|
|
tbody.innerHTML = '<tr><td colspan="9" class="p-4">No instruments found in CSV.</td></tr>';
|
|
return;
|
|
}
|
|
|
|
data.forEach(item => {
|
|
// Helper to format EMA offsets with +/- and Colors
|
|
const formatEma = (val) => {
|
|
if (val === "N/A" || val === null) return `<span class="text-muted">N/A</span>`;
|
|
const sign = val > 0 ? "+" : "";
|
|
const colorClass = val >= 0 ? 'text-up' : 'text-down';
|
|
return `<span class="${colorClass}">${sign}${val}%</span>`;
|
|
};
|
|
|
|
const row = `
|
|
<tr>
|
|
<td>${item.symbol}</td>
|
|
<td class="fw-bold">${item.last_close}</td>
|
|
<td class="${item.change_pct >= 0 ? 'text-up' : 'text-down'}">
|
|
${item.change_pct >= 0 ? '+' : ''}${item.change_pct}%
|
|
</td>
|
|
<td class="text-muted small">${item.low_52} - ${item.high_52}</td>
|
|
<td>${formatEma(item.last_ema20)}</td>
|
|
<td>${formatEma(item.last_ema50)}</td>
|
|
<td>${formatEma(item.last_ema100)}</td>
|
|
<td>${formatEma(item.last_ema200)}</td>
|
|
<td><span class="badge badge-kd">${item.kd_values}</span></td>
|
|
</tr>
|
|
`;
|
|
tbody.innerHTML += row;
|
|
});
|
|
} catch (error) {
|
|
console.error("Fetch error:", error);
|
|
tbody.innerHTML = '<tr><td colspan="9" class="text-danger p-4">Error connecting to server.</td></tr>';
|
|
} finally {
|
|
loading.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Initial Load
|
|
document.addEventListener('DOMContentLoaded', loadData);
|
|
</script>
|
|
|
|
</body>
|
|
</html> |