update
This commit is contained in:
parent
070d505b3f
commit
dd6e51400e
@ -399,7 +399,13 @@ class DepartmentAgent:
|
|||||||
lines.append(f"- {table}: 已返回窗口 {window} 的数据,跳过重复请求")
|
lines.append(f"- {table}: 已返回窗口 {window} 的数据,跳过重复请求")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
rows = self._broker.fetch_table_rows(table, ts_code, trade_date, window)
|
rows = self._broker.fetch_table_rows(
|
||||||
|
table,
|
||||||
|
ts_code,
|
||||||
|
trade_date,
|
||||||
|
window,
|
||||||
|
auto_refresh=False # 避免在回测过程中触发自动补数
|
||||||
|
)
|
||||||
if rows:
|
if rows:
|
||||||
preview = ", ".join(
|
preview = ", ".join(
|
||||||
f"{row.get('trade_date', 'NA')}" for row in rows[: min(len(rows), 5)]
|
f"{row.get('trade_date', 'NA')}" for row in rows[: min(len(rows), 5)]
|
||||||
|
|||||||
@ -139,6 +139,7 @@ class BacktestEngine:
|
|||||||
ts_code,
|
ts_code,
|
||||||
trade_date_str,
|
trade_date_str,
|
||||||
self.required_fields,
|
self.required_fields,
|
||||||
|
auto_refresh=False # 避免回测时触发自动补数
|
||||||
)
|
)
|
||||||
|
|
||||||
closes = self.data_broker.fetch_series(
|
closes = self.data_broker.fetch_series(
|
||||||
@ -147,6 +148,7 @@ class BacktestEngine:
|
|||||||
ts_code,
|
ts_code,
|
||||||
trade_date_str,
|
trade_date_str,
|
||||||
window=60,
|
window=60,
|
||||||
|
auto_refresh=False, # 避免在回测中触发自动补数
|
||||||
)
|
)
|
||||||
close_values = [value for _date, value in closes if value is not None]
|
close_values = [value for _date, value in closes if value is not None]
|
||||||
|
|
||||||
@ -171,6 +173,7 @@ class BacktestEngine:
|
|||||||
ts_code,
|
ts_code,
|
||||||
trade_date_str,
|
trade_date_str,
|
||||||
window=20,
|
window=20,
|
||||||
|
auto_refresh=False, # 避免在回测中触发自动补数
|
||||||
)
|
)
|
||||||
turnover_values = [value for _date, value in turnover_series if value is not None]
|
turnover_values = [value for _date, value in turnover_series if value is not None]
|
||||||
|
|
||||||
@ -255,9 +258,10 @@ class BacktestEngine:
|
|||||||
is_suspended = self.data_broker.fetch_flags(
|
is_suspended = self.data_broker.fetch_flags(
|
||||||
"suspend",
|
"suspend",
|
||||||
ts_code,
|
ts_code,
|
||||||
trade_date_str,
|
trade_date,
|
||||||
"suspend_date <= ? AND (resume_date IS NULL OR resume_date > ?)",
|
"trade_date = ?",
|
||||||
(trade_date_str, trade_date_str),
|
[trade_date],
|
||||||
|
auto_refresh=False, # 避免在回测中触发自动补数
|
||||||
)
|
)
|
||||||
|
|
||||||
features = {
|
features = {
|
||||||
@ -511,7 +515,7 @@ class BacktestEngine:
|
|||||||
if not price_map and state.holdings:
|
if not price_map and state.holdings:
|
||||||
trade_date_compact = trade_date.strftime("%Y%m%d")
|
trade_date_compact = trade_date.strftime("%Y%m%d")
|
||||||
for ts_code in list(state.holdings.keys()):
|
for ts_code in list(state.holdings.keys()):
|
||||||
fetched = self.data_broker.fetch_latest(ts_code, trade_date_compact, ["daily.close"])
|
fetched = self.data_broker.fetch_latest(ts_code, trade_date_compact, ["daily.close"], auto_refresh=False)
|
||||||
price = fetched.get("daily.close")
|
price = fetched.get("daily.close")
|
||||||
if price:
|
if price:
|
||||||
price_map[ts_code] = float(price)
|
price_map[ts_code] = float(price)
|
||||||
|
|||||||
@ -377,6 +377,7 @@ class DataBroker:
|
|||||||
trade_date: str,
|
trade_date: str,
|
||||||
where_clause: str,
|
where_clause: str,
|
||||||
params: Sequence[object],
|
params: Sequence[object],
|
||||||
|
auto_refresh: bool = True,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Generic helper to test if a record exists (used for limit/suspend lookups)."""
|
"""Generic helper to test if a record exists (used for limit/suspend lookups)."""
|
||||||
|
|
||||||
@ -415,6 +416,7 @@ class DataBroker:
|
|||||||
ts_code: str,
|
ts_code: str,
|
||||||
trade_date: str,
|
trade_date: str,
|
||||||
window: int,
|
window: int,
|
||||||
|
auto_refresh: bool = True,
|
||||||
) -> List[Dict[str, object]]:
|
) -> List[Dict[str, object]]:
|
||||||
if window <= 0:
|
if window <= 0:
|
||||||
return []
|
return []
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user