Fix CH portfolio: increase reload delay and enable auto-refresh
Browse files- Increase post-order reload from 1.5s to 4s to allow Kafka round-trip
(order → matcher → trade → CH consumer → DB) to complete
- Fix auto-refresh: was fetching data but not updating the page;
now reloads every 10s so trades are reflected promptly
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
clearing_house/templates/portfolio.html
CHANGED
|
@@ -212,8 +212,8 @@ document.getElementById('order-form').addEventListener('submit', async function(
|
|
| 212 |
msg.style.background = 'rgba(63,185,80,.12)';
|
| 213 |
msg.style.border = '1px solid var(--green)';
|
| 214 |
msg.style.color = 'var(--green)';
|
| 215 |
-
msg.textContent = `Order submitted: ${data.side} ${data.quantity} ${data.symbol} @ €${data.price}`;
|
| 216 |
-
setTimeout(() => location.reload(),
|
| 217 |
} else {
|
| 218 |
msg.className = 'flash flash-error';
|
| 219 |
msg.textContent = result.error || 'Order failed';
|
|
@@ -225,14 +225,6 @@ document.getElementById('order-form').addEventListener('submit', async function(
|
|
| 225 |
}
|
| 226 |
});
|
| 227 |
|
| 228 |
-
// Auto-refresh portfolio every
|
| 229 |
-
setInterval(
|
| 230 |
-
try {
|
| 231 |
-
const resp = await fetch('/ch/api/portfolio');
|
| 232 |
-
if (!resp.ok) return;
|
| 233 |
-
const d = await resp.json();
|
| 234 |
-
// Just reload the page for simplicity
|
| 235 |
-
// (A production app would do a DOM patch)
|
| 236 |
-
} catch(e) {}
|
| 237 |
-
}, 15000);
|
| 238 |
{% endblock %}
|
|
|
|
| 212 |
msg.style.background = 'rgba(63,185,80,.12)';
|
| 213 |
msg.style.border = '1px solid var(--green)';
|
| 214 |
msg.style.color = 'var(--green)';
|
| 215 |
+
msg.textContent = `Order submitted: ${data.side} ${data.quantity} ${data.symbol} @ €${data.price} — waiting for execution...`;
|
| 216 |
+
setTimeout(() => location.reload(), 4000);
|
| 217 |
} else {
|
| 218 |
msg.className = 'flash flash-error';
|
| 219 |
msg.textContent = result.error || 'Order failed';
|
|
|
|
| 225 |
}
|
| 226 |
});
|
| 227 |
|
| 228 |
+
// Auto-refresh portfolio every 10 seconds
|
| 229 |
+
setInterval(() => location.reload(), 10000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
{% endblock %}
|