feat: WBS-1.2 total_asset_krw 실시간 재계산 구현

This commit is contained in:
2026-06-13 13:51:25 +09:00
parent 8979ee7689
commit 63de4b922f
@@ -2054,7 +2054,7 @@ function runDataFeed() {
// settings 탭 — 사용자 입력 파라미터 (total_asset_krw, risk_budget_override 등)
const settings = readSettingsTab_();
ensureAccountSnapshotConfirmModeSetting_(settings);
const totalAssetKrw_ = Number.isFinite(parseFloat(settings["total_asset_krw"]))
let totalAssetKrw_ = Number.isFinite(parseFloat(settings["total_asset_krw"]))
? parseFloat(settings["total_asset_krw"]) : null;
const riskBudget_ = Number.isFinite(parseFloat(settings["risk_budget_override"]))
? Math.min(0.02, Math.max(0, parseFloat(settings["risk_budget_override"])))
@@ -2193,6 +2193,20 @@ function runDataFeed() {
};
});
// WBS-1.2: total_asset_krw 실시간 재계산 (2-pass update cycle)
let liveTotalAssetKrw = Number.isFinite(settlementCashD2_) ? settlementCashD2_ : 0;
for (const ticker of Object.keys(positionStopMap_)) {
const priceMetrics = resolveDataFeedPriceMetrics(ticker);
const qty = positionStopMap_[ticker].quantity;
if (priceMetrics.ok && Number.isFinite(priceMetrics.close) && Number.isFinite(qty)) {
liveTotalAssetKrw += priceMetrics.close * qty;
}
}
if (liveTotalAssetKrw > 0) {
totalAssetKrw_ = liveTotalAssetKrw;
Logger.log(`[WBS-1.2] total_asset_krw 실시간 재계산 완료: ${totalAssetKrw_} KRW (현금: ${settlementCashD2_})`);
}
// Total_Heat 사전 계산 — HF005(≥10% 매수 차단) + caution(7~10% 수량 감액)에 사용
// positionStopMap_ 완성 후 즉시 계산. ATR 추정 폴백: entry_price × 8% (보수적)
let globalHeatPct_ = null; // null = 계산 불가, number = heat%