fix(HEL-494): 盘中双免费源故障切换并禁止问天假0覆盖
主源东财失败后自动改走腾讯行情,成功结果写入缓存;两源都失败时返回最近真实快照并标明延迟,不再显示假0。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
b5d65ecb41
commit
ef13d6feb5
@@ -299,6 +299,14 @@ class HeavenMarketContextMixin:
|
||||
and not cached.get("realtime")
|
||||
and int(cached.get("schema_version") or 0) >= 6
|
||||
)
|
||||
cached_quotes = int((cached or {}).get("quote_count") or 0)
|
||||
cached_lkg = bool(
|
||||
cached
|
||||
and cached_date == trade_date
|
||||
and cached.get("taxonomy") == "sw_l2"
|
||||
and cached_quotes > 0
|
||||
and int(cached.get("schema_version") or 0) >= 6
|
||||
)
|
||||
if market_mode != "intraday" and cached_valid:
|
||||
return cached
|
||||
if not self.configured:
|
||||
@@ -311,8 +319,12 @@ class HeavenMarketContextMixin:
|
||||
allow_realtime_close=market_mode == "closed",
|
||||
)
|
||||
except TushareError as exc:
|
||||
if cached_valid:
|
||||
return cached
|
||||
if cached_lkg:
|
||||
delayed = dict(cached)
|
||||
delayed["delayed"] = True
|
||||
delayed["delay_notice"] = "主备免费行情均暂不可用,显示最近一次真实快照"
|
||||
delayed["realtime"] = market_mode == "intraday"
|
||||
return delayed
|
||||
return {
|
||||
"name": "",
|
||||
"code": "",
|
||||
@@ -323,12 +335,16 @@ class HeavenMarketContextMixin:
|
||||
"precise": False,
|
||||
"inner_precise": False,
|
||||
"outer_precise": False,
|
||||
"coverage": 0,
|
||||
"member_count": 0,
|
||||
"quote_count": 0,
|
||||
"error": f"申万二级行业数据获取失败:{exc}",
|
||||
}
|
||||
if not payload.get("realtime") and payload.get("precise"):
|
||||
if int(payload.get("quote_count") or 0) > 0:
|
||||
self.database.save_data_snapshot(
|
||||
"heaven_sector",
|
||||
cache_key,
|
||||
str(payload.get("source") or "tushare"),
|
||||
payload,
|
||||
)
|
||||
elif not payload.get("realtime") and payload.get("precise"):
|
||||
self.database.save_data_snapshot(
|
||||
"heaven_sector",
|
||||
cache_key,
|
||||
|
||||
@@ -243,6 +243,7 @@ class HeavenTrendMixin:
|
||||
"detail": (
|
||||
f"申万二级 {sector.get('name') or '--'} {sector.get('code') or '--'} "
|
||||
f"成分覆盖 {int(sector.get('quote_count') or 0)}/{int(sector.get('member_count') or 0)}"
|
||||
+ (";延迟快照" if sector.get("delayed") or sector.get("delay_notice") else "")
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -341,7 +342,9 @@ class HeavenTrendMixin:
|
||||
issues.append("行业外显缺少申万官方行情")
|
||||
if sector and sector_coverage_issue:
|
||||
issues.append(sector_coverage_issue)
|
||||
if sector.get("realtime") and not sector.get("relative_turnover"):
|
||||
if sector.get("delay_notice"):
|
||||
issues.append(str(sector.get("delay_notice")))
|
||||
if sector.get("realtime") and not sector.get("relative_turnover") and not sector.get("delayed"):
|
||||
issues.append("行业内核缺少相对全市场换手活跃度")
|
||||
|
||||
stock = stock or {}
|
||||
|
||||
Reference in New Issue
Block a user