fix(HEL-494): 修复个股缺失指标、问天遮罩、四爻外显并回补250日K

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总工
2026-09-08 16:26:13 +08:00
co-authored by Cursor multica-agent
parent c8a9376adb
commit 3e828b346c
24 changed files with 1011 additions and 160 deletions
+67 -2
View File
@@ -5,6 +5,7 @@ from typing import Any
from backend.data.numbers import finite_number as _number
from backend.data.providers.tushare_helpers import (
_display_time,
_optional_number,
_prices_equal,
calendar_is_open,
)
@@ -137,7 +138,67 @@ class DailyMarketMixin:
)
item["capital_trade_date"] = str(capital.get("trade_date") or "")
result.append(item)
return result
return self._overlay_board_fields(result, trade_date)
def _overlay_board_fields(
self,
rows: list[dict[str, Any]],
trade_date: str,
) -> list[dict[str, Any]]:
if not rows:
return rows
official = self._official_board_map(trade_date)
free = self._free_board_map(trade_date) if not official else {}
merged: list[dict[str, Any]] = []
for row in rows:
code = str(row.get("ts_code") or "")
extra = official.get(code) or free.get(code) or {}
if not extra:
merged.append(row)
continue
item = dict(row)
for key in (
"first_time",
"last_time",
"fd_amount",
"open_times",
"limit_times",
"turnover_ratio",
):
incoming = extra.get(key)
current = item.get(key)
if incoming in (None, "", "--"):
continue
if current in (None, "", "--", 0, 0.0):
item[key] = incoming
merged.append(item)
return merged
def _official_board_map(self, trade_date: str) -> dict[str, dict[str, Any]]:
mapped: dict[str, dict[str, Any]] = {}
try:
for row in self._load_limit_lists(trade_date):
code = str(row.get("ts_code") or "")
if code:
mapped[code] = row
except Exception:
return {}
return mapped
def _free_board_map(self, trade_date: str) -> dict[str, dict[str, Any]]:
aggregator = getattr(self, "realtime_aggregator", None)
loader = getattr(aggregator, "eastmoney_limit_pool", None) if aggregator else None
if not callable(loader):
return {}
try:
rows = loader(trade_date)
except Exception:
return {}
return {
str(row.get("ts_code") or ""): row
for row in rows
if row.get("ts_code")
}
@staticmethod
def _normalize_limit(row: dict[str, Any], status: str) -> dict[str, Any]:
@@ -162,7 +223,11 @@ class DailyMarketMixin:
"turnover_source": row.get("turnover_source") or "provider",
"capital_trade_date": row.get("capital_trade_date") or "",
"amount_billion": round(amount_billion, 2),
"seal_amount_million": round(_number(row.get("fd_amount")) / 10000, 0),
"seal_amount_million": (
round(fd / 10000, 0)
if (fd := _optional_number(row.get("fd_amount"))) is not None
else None
),
"float_mv_billion": round(_number(row.get("float_mv")) / 100000000, 1),
"status": status,
}