fix(HEL-356): use completed history for intraday metrics
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -467,7 +467,10 @@ class DashboardMixin:
|
||||
{
|
||||
"ts_code": ts_code,
|
||||
"start_date": (end - timedelta(days=30)).strftime("%Y%m%d"),
|
||||
"end_date": reference_date,
|
||||
# Intraday bars are not official daily history yet. Asking
|
||||
# the hub for today's daily row makes a complete historical
|
||||
# range look incomplete and discards otherwise valid data.
|
||||
"end_date": (end - timedelta(days=1)).strftime("%Y%m%d"),
|
||||
},
|
||||
"ts_code,trade_date,vol,amount",
|
||||
)
|
||||
@@ -592,7 +595,13 @@ class DashboardMixin:
|
||||
start_date = (end - timedelta(days=20)).strftime("%Y%m%d")
|
||||
rows = self.query(
|
||||
"daily_basic",
|
||||
{"ts_code": ts_code, "start_date": start_date, "end_date": end_date},
|
||||
{
|
||||
"ts_code": ts_code,
|
||||
"start_date": start_date,
|
||||
# Same rule as price history: today's official valuation is
|
||||
# unavailable during the session, so use the latest prior row.
|
||||
"end_date": (end - timedelta(days=1)).strftime("%Y%m%d"),
|
||||
},
|
||||
"ts_code,trade_date,turnover_rate,volume_ratio,total_share,float_share,"
|
||||
"free_share,total_mv,circ_mv",
|
||||
)
|
||||
|
||||
@@ -217,11 +217,14 @@ class HeavenMarketContextMixin:
|
||||
start_date = (
|
||||
datetime.strptime(trade_date, "%Y%m%d") - timedelta(days=20)
|
||||
).strftime("%Y%m%d")
|
||||
history_end = (
|
||||
datetime.strptime(trade_date, "%Y%m%d") - timedelta(days=1)
|
||||
).strftime("%Y%m%d")
|
||||
for quote in quotes:
|
||||
ts_code = code_map[str(quote.get("code") or "")]
|
||||
history = client.query(
|
||||
"index_daily",
|
||||
{"ts_code": ts_code, "start_date": start_date, "end_date": trade_date},
|
||||
{"ts_code": ts_code, "start_date": start_date, "end_date": history_end},
|
||||
"ts_code,trade_date,close,pct_chg",
|
||||
)
|
||||
history.sort(key=lambda item: str(item.get("trade_date") or ""))
|
||||
|
||||
Reference in New Issue
Block a user