fix(HEL-356): restore intraday turnover context

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总管
2026-09-09 11:41:44 +08:00
co-authored by multica-agent
parent abee8306be
commit 5f343a6bae
5 changed files with 34 additions and 10 deletions
+1 -2
View File
@@ -22,8 +22,7 @@ class HubRealtimeProxy:
except RealtimeAggregateError as exc:
error = str(exc)
epochs = [int(item.get("quote_time_epoch") or 0) for item in indices]
now = datetime.now().astimezone()
max_skew = 120 if now.hour >= 15 else 15
max_skew = 120
index_consistent = bool(epochs) and max(epochs) - min(epochs) <= max_skew
ready = len(indices) == 3 and index_consistent
return {
@@ -368,6 +368,11 @@ class DashboardMixin:
basic = basics[0] if basics else {}
capital = self._latest_capital(ts_code, reference_date)
float_share = _number(capital.get("float_share"))
if not float_share and previous_close:
# The hub's canonical valuation table stores market values but not
# share counts. circ_mv (10k CNY) / price (CNY) is float shares in
# 10k shares, the same unit used by the turnover formula below.
float_share = _number(capital.get("circ_mv")) / previous_close
# rt_k volume is shares; daily_basic float_share is reported in 10k shares.
turnover_rate = _number(row.get("vol")) / float_share / 100 if float_share else 0
market_date = reference_date or datetime.now().astimezone().strftime("%Y%m%d")
@@ -389,6 +394,13 @@ class DashboardMixin:
for item in market_rows:
item_capital = capital_map.get(str(item.get("ts_code") or ""), {})
item_float_share = _number(item_capital.get("float_share"))
item_previous = _number(
item.get("pre_close")
if item.get("pre_close") not in (None, "")
else item.get("previous_close")
)
if not item_float_share and item_previous:
item_float_share = _number(item_capital.get("circ_mv")) / item_previous
if item_float_share:
market_turnovers.append(_number(item.get("vol")) / item_float_share / 100)
market_turnover = (
@@ -541,6 +541,13 @@ class ShenwanIndustryMixin:
for item in valid:
capital = capital_map.get(str(item.get("ts_code") or ""), {})
float_share = _number(capital.get("float_share"))
previous = _number(
item.get("pre_close")
if item.get("pre_close") not in (None, "")
else item.get("previous_close")
)
if not float_share and previous:
float_share = _number(capital.get("circ_mv")) / previous
volume = _number(item.get("vol"))
if float_share and volume:
# 免费源成交量为股;daily_basic.float_share 为万股。
@@ -549,6 +556,13 @@ class ShenwanIndustryMixin:
for item in market_rows:
capital = capital_map.get(str(item.get("ts_code") or ""), {})
float_share = _number(capital.get("float_share"))
previous = _number(
item.get("pre_close")
if item.get("pre_close") not in (None, "")
else item.get("previous_close")
)
if not float_share and previous:
float_share = _number(capital.get("circ_mv")) / previous
volume = _number(item.get("vol"))
if float_share and volume:
market_turnovers.append(volume / float_share / 100)
+1 -2
View File
@@ -202,8 +202,7 @@ class HeavenMarketContextMixin:
}
if len(quotes) != 3 or quote_dates != {trade_date}:
raise ValueError("腾讯三大指数日期与目标交易日不一致")
now = datetime.now().astimezone()
max_skew = 120 if now.hour >= 15 else 15
max_skew = 120
if max(epochs) - min(epochs) > max_skew:
raise ValueError(f"腾讯三大指数时间差超过{max_skew}秒")
+6 -6
View File
@@ -483,8 +483,8 @@
},
{
"path": "backend/data/providers/tushare_industries.py",
"bytes": 37168,
"lines": 859
"bytes": 37786,
"lines": 873
},
{
"path": "backend/features/screener/catalog.py",
@@ -498,8 +498,8 @@
},
{
"path": "backend/data/providers/tushare_dashboard.py",
"bytes": 34082,
"lines": 785
"bytes": 34777,
"lines": 797
},
{
"path": "database.py",
@@ -568,8 +568,8 @@
},
{
"path": "backend/features/heaven/market_context.py",
"bytes": 14535,
"lines": 357
"bytes": 14467,
"lines": 356
},
{
"path": "frontend/shared/session.js",