unknownfriend00007 commited on
Commit
7d4fcd5
·
verified ·
1 Parent(s): 8004930

Create templates/dashboard.html

Browse files
Files changed (1) hide show
  1. templates/dashboard.html +108 -0
templates/dashboard.html ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>Tarang v2</title>
7
+ <style>
8
+ body { font-family: system-ui, Arial; background:#0b0f19; color:#e6e6e6; margin:0; }
9
+ .wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
10
+ .card { background:#121a2a; border:1px solid #22304f; border-radius:14px; padding:16px; margin:12px 0; }
11
+ button { background:#6d28d9; border:0; color:white; padding:10px 14px; border-radius:10px; cursor:pointer; }
12
+ button:disabled { opacity:.6; cursor:not-allowed; }
13
+ table { width:100%; border-collapse: collapse; }
14
+ th, td { padding:10px; border-bottom:1px solid #22304f; text-align:left; }
15
+ .muted { color:#9aa4b2; font-size: 13px; }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <div class="wrap">
20
+ <h1>Tarang v2 — Daily Forecast</h1>
21
+ <div class="muted">Loads data from <code>historical_data/</code>, trains a small model on CPU, and serves next-day predictions.</div>
22
+
23
+ <div class="card">
24
+ <button onclick="loadAll()">Refresh</button>
25
+ <span id="status" class="muted"></span>
26
+ </div>
27
+
28
+ <div class="card">
29
+ <h3>Predictions</h3>
30
+ <div class="muted">Sorted by biggest absolute predicted move.</div>
31
+ <div style="overflow:auto">
32
+ <table id="predTable">
33
+ <thead>
34
+ <tr>
35
+ <th>Symbol</th>
36
+ <th>Type</th>
37
+ <th>Last date</th>
38
+ <th>Predicted for</th>
39
+ <th>Pred % return</th>
40
+ <th>Last close</th>
41
+ <th>Pred close</th>
42
+ </tr>
43
+ </thead>
44
+ <tbody></tbody>
45
+ </table>
46
+ </div>
47
+ </div>
48
+
49
+ <div class="card">
50
+ <h3>Debug</h3>
51
+ <pre id="debug" style="white-space:pre-wrap"></pre>
52
+ </div>
53
+ </div>
54
+
55
+ <script>
56
+ async function loadAll() {
57
+ const statusEl = document.getElementById("status");
58
+ const debugEl = document.getElementById("debug");
59
+ statusEl.textContent = "Loading...";
60
+ debugEl.textContent = "";
61
+
62
+ const s = await fetch("/api/status").then(r=>r.json());
63
+ debugEl.textContent += "STATUS:\n" + JSON.stringify(s, null, 2) + "\n\n";
64
+
65
+ if (!s.ok) {
66
+ statusEl.textContent = "Status error.";
67
+ return;
68
+ }
69
+ if (s.training) {
70
+ statusEl.textContent = "Training in progress... wait and refresh.";
71
+ return;
72
+ }
73
+ if (s.error) {
74
+ statusEl.textContent = "Error: " + s.error;
75
+ return;
76
+ }
77
+
78
+ const p = await fetch("/api/predict").then(r=>r.json());
79
+ debugEl.textContent += "PREDICT:\n" + JSON.stringify(p, null, 2);
80
+
81
+ const tbody = document.querySelector("#predTable tbody");
82
+ tbody.innerHTML = "";
83
+ if (!p.ok) {
84
+ statusEl.textContent = "Predict error: " + p.error;
85
+ return;
86
+ }
87
+
88
+ for (const row of p.predictions) {
89
+ const tr = document.createElement("tr");
90
+ tr.innerHTML = `
91
+ <td>${row.symbol}</td>
92
+ <td>${row.asset_type}</td>
93
+ <td>${row.last_date}</td>
94
+ <td>${row.predicted_for}</td>
95
+ <td>${row.pred_pct_return.toFixed(3)}%</td>
96
+ <td>${row.last_close.toFixed(3)}</td>
97
+ <td>${row.pred_close.toFixed(3)}</td>
98
+ `;
99
+ tbody.appendChild(tr);
100
+ }
101
+
102
+ statusEl.textContent = `Loaded ${p.count} predictions.`;
103
+ }
104
+
105
+ loadAll();
106
+ </script>
107
+ </body>
108
+ </html>