Fix recommend table missing trend/daily stats when CTP klines are sparse.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user