diff --git a/deploy/profile-scripts/price_monitor.py b/deploy/profile-scripts/price_monitor.py index a9105ff6..7ba00e24 100644 --- a/deploy/profile-scripts/price_monitor.py +++ b/deploy/profile-scripts/price_monitor.py @@ -469,10 +469,16 @@ def refresh_data_prices(): db_holdings.append(h) # ── 写 holdings 表 ── + # 2026-08-25 币种 normalize(holdings 里是中文"人民币/港币"——import_holding_xls/trade_capture + # 导入时写入的;旧校验 raise 杀死整个 refresh 循环,live_prices 停滞 70 分钟根因) + _CUR_MAP = {"人民币": "CNY", "港币": "HKD", "CNY": "CNY", "HKD": "HKD", "RMB": "CNY"} for h in db_holdings: - currency = str(h.get('currency', 'CNY')).upper() - if currency not in ('CNY', 'HKD'): - raise ValueError(f"非法币种: {currency}") + _raw_cur = str(h.get('currency', 'CNY')).strip() + currency = _CUR_MAP.get(_raw_cur) or _CUR_MAP.get(_raw_cur.upper()) + if not currency: + print(f"[刷新] {h.get('code')} 币种'{_raw_cur}'无法识别,默认CNY", file=sys.stderr) + currency = 'CNY' + h['currency'] = currency # normalize 后写回, holdings 表自我修复 conn.execute(""" INSERT INTO holdings (code, name, shares, cost, price, market_value, change_pct, currency, position_pct, added_at, is_active)