fix(okx): cache options balances and stop SSE from hammering exchange API

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 11:15:06 +08:00
parent 799a4d6b8b
commit 2ad9e049f3
6 changed files with 82 additions and 37 deletions
@@ -1054,8 +1054,10 @@ function formatOptionsFundingLabel(usdc, usdt) {
return parts.length ? parts.join(" · ") : "—";
}
function refreshAccountSnapshot(){
fetch("/api/account_snapshot").then(r=>r.json()).then(data=>{
function refreshAccountSnapshot(opts){
const options = opts || {};
const qs = options.force ? "?force=1" : "";
fetch("/api/account_snapshot" + qs).then(r=>r.json()).then(data=>{
if (typeof data.funding_usdt !== "undefined") {
const el = document.getElementById("total-capital");
if(el) el.innerText = (data.funding_usdt === null || data.funding_usdt === undefined) ? "—" : `${Number(data.funding_usdt).toFixed(2)}U`;
@@ -1186,7 +1188,7 @@ if(window.ManualOrderRrPreview){
refreshAccountSnapshot();
const settingsRefreshFunds = document.getElementById("settings-refresh-funds");
if (settingsRefreshFunds) settingsRefreshFunds.addEventListener("click", refreshAccountSnapshot);
if (settingsRefreshFunds) settingsRefreshFunds.addEventListener("click", function(){ refreshAccountSnapshot({ force: true }); });
if (window.AccountRiskBadge) AccountRiskBadge.startTicker();
const _journalFormEl = document.getElementById("journal-form");
if(_journalFormEl){