fix(risk): correct freeze countdown timezone (Asia/Shanghai)

Treat naive app datetimes as local time, normalize legacy UTC-ms rows, and resolve cooloff end from stored until or last_close+duration.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-18 18:00:40 +08:00
parent f8e760961e
commit ff8caf7f8d
3 changed files with 118 additions and 28 deletions
+3 -1
View File
@@ -70,6 +70,7 @@ RISK_COOLING_HOURS_MANUAL_JOURNAL=1
RISK_MANUAL_CLOSE_DAILY_LIMIT=2
RISK_MOOD_ISSUES_DAILY_FREEZE=true
TRADING_DAY_RESET_HOUR=8
APP_TIMEZONE=Asia/Shanghai
```
`RISK_COOLING_HOURS_EXTERNAL` 已废弃(外部平仓不再触发风控)。
@@ -99,7 +100,8 @@ TRADING_DAY_RESET_HOUR=8
- 共用脚本:`static/account_risk_badge.js`(实例 `/static/…`,中控 `/assets/account_risk_badge.js`
- 样式:`static/account_risk_badge.css`
- 中控 `app.js``formatRiskStatusBadge()` 与实例 `refreshAccountSnapshot()` 均调用 `AccountRiskBadge`
- 展示格式:`4h冻结 · 3h 12m`;日冻结为距下一交易日切点剩余时间
- 时间戳按 **`APP_TIMEZONE`(默认 `Asia/Shanghai`** 计算,与实例 `app_now()` 一致;旧版 naive-as-UTC 写入的库内毫秒会自动修正
## 相关代码