diff --git a/modules/market/kline_chart.py b/modules/market/kline_chart.py index 4724693..8b83fc0 100644 --- a/modules/market/kline_chart.py +++ b/modules/market/kline_chart.py @@ -317,7 +317,8 @@ def fetch_market_klines( except Exception as exc: logger.debug("ctp kline fetch failed %s %s: %s", symbol, p, exc) - need_sina = not prefer_ctp or force_remote + # prefer_ctp 时 CTP bar 不足仍须用新浪/本地缓存补齐(否则走势、跳空等日线统计为空) + need_sina = force_remote or not prefer_ctp or len(ctp_bars) < MIN_CTP_KLINE_BARS if ctp_bars and len(ctp_bars) >= MIN_CTP_KLINE_BARS: bars = ctp_bars source = "ctp" diff --git a/modules/trading/recommend_store.py b/modules/trading/recommend_store.py index 5c4f40e..96d2d04 100644 --- a/modules/trading/recommend_store.py +++ b/modules/trading/recommend_store.py @@ -51,17 +51,24 @@ def rows_missing_max_lots(rows: list[dict]) -> bool: def rows_missing_trend(rows: list[dict]) -> bool: - """缓存是否为旧版(缺少走势字段)。""" + """缓存是否为旧版(缺少走势字段或走势未算出)。""" if not rows: return False - return any("trend" not in r for r in rows) + return any("trend" not in r or not str(r.get("trend") or "").strip() for r in rows) def rows_missing_daily_stats(rows: list[dict]) -> bool: - """缓存是否为旧版(缺少跳空/量价字段)。""" + """缓存是否为旧版(缺少跳空/量价字段或日线统计未算出)。""" if not rows: return False - return any("gap" not in r for r in rows) + return any( + r.get("status") in ("ok", "margin_ok") + and ( + "gap" not in r + or r.get("prev_close") in (None, "", 0) + ) + for r in rows + ) def rows_missing_category(rows: list[dict]) -> bool: