fix(data): judge late newest rows as sparse; require SPY print only in the ETF panel

Tickers count as alive for 10 rows after their last bar, so a newest row
printed by a few early tickers is dropped until the rest arrive. The
benchmark-print session rule now applies only to the mixed US/HK ETF panel:
Yahoo's 510300.SS lags CN stocks by days and would stall the CN book.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-25 01:51:02 +08:00
parent 1697bc1641
commit 0d3642435b
3 changed files with 16 additions and 5 deletions

View File

@@ -362,12 +362,13 @@ def completed_sessions(close_raw: pd.DataFrame, data_market: str, benchmark: str
now: datetime | None = None) -> pd.DatetimeIndex:
"""Trading days whose closing prices are final.
A day counts when the benchmark printed a bar on it. Today's bar is
excluded until the exchange has closed and settled, because before that
it is an intraday snapshot rather than a close.
Stored panel rows are trading days (sparse rows are dropped on update).
The ETF panel mixes US and HK listings, so there a day also needs a
benchmark (SPY) print. Today's bar is excluded until the exchange has
closed and settled, because before that it is an intraday snapshot.
"""
index = close_raw.index
if benchmark in close_raw.columns:
if data_market == "etfs" and benchmark in close_raw.columns:
index = index[close_raw[benchmark].notna().to_numpy()]
tz_name, hour, minute = MARKET_SESSION.get(data_market, MARKET_SESSION["us"])
now_local = (now or datetime.now(timezone.utc)).astimezone(zoneinfo.ZoneInfo(tz_name))