fix(HEL-164): 撤回盘后刷新改动并恢复原逻辑

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总管
2026-08-28 09:05:42 +00:00
co-authored by multica-agent
parent 6d7a839202
commit f27471238a
5 changed files with 22 additions and 278 deletions
+2 -33
View File
@@ -188,30 +188,6 @@ class MarketServiceMixin:
age_seconds = (now - updated_at.astimezone(now.tzinfo)).total_seconds()
return age_seconds >= 8
def _closing_snapshot_due(
self,
normalized_date: str,
snapshot: dict[str, Any],
) -> bool:
"""After 15:05, keep requesting daily bars until today's EOD snapshot exists."""
if not self.configured or normalized_date != date.today().strftime("%Y%m%d"):
return False
now = datetime.now().astimezone()
if now.weekday() >= 5:
return False
local_time = now.time().replace(tzinfo=None)
if local_time < datetime.strptime("15:05", "%H:%M").time():
return False
meta = snapshot.get("meta") or {}
snapshot_trade_date = str(meta.get("trade_date") or "").replace("-", "")
if (
snapshot_trade_date == normalized_date
and not meta.get("realtime")
and not meta.get("carried_forward")
):
return False
return True
def sync_dashboard(self, trade_date: str) -> dict[str, Any]:
normalized_date = normalize_date(trade_date)
source = "tushare"
@@ -256,15 +232,9 @@ class MarketServiceMixin:
fallback, normalized_date, f"最新行情暂不可用,沿用最近收盘快照:{exc}"
)
self.database.finish_sync(
sync_id, "failed", self._record_count(carried), str(exc), "tushare"
sync_id, "fallback", self._record_count(carried), str(exc), "tushare"
)
result = self._apply_reason_overrides(
self._with_storage(carried, cached=True)
)
# 页面仍可读到沿用快照;后台任务通过顶层 status=failed 记失败。
result["status"] = "failed"
result["error"] = str(exc)
return result
return self._apply_reason_overrides(self._with_storage(carried, cached=True))
self.database.finish_sync(sync_id, "failed", message=str(exc))
raise ValueError("暂无可用的真实行情快照,请等待后台完成首次同步。") from exc
except Exception as exc:
@@ -1193,4 +1163,3 @@ class MarketServiceMixin:
len(dashboard.get(key) or [])
for key in ("limits", "broken", "down_limits", "yesterday_limits")
)