refactor boot check to streamline data ingestion and factor calculation process
This commit is contained in:
parent
393a40cb79
commit
f3f95580bc
@ -49,26 +49,30 @@ def run_boot_check(
|
|||||||
start, end = _default_window(days)
|
start, end = _default_window(days)
|
||||||
LOGGER.info("开机检查覆盖窗口:%s 至 %s", start, end)
|
LOGGER.info("开机检查覆盖窗口:%s 至 %s", start, end)
|
||||||
|
|
||||||
from app.ingest.tushare import FetchJob, run_ingestion
|
|
||||||
|
|
||||||
# 创建数据拉取任务,这样会自动触发因子计算
|
|
||||||
job = FetchJob(
|
|
||||||
name="ui_auto_update",
|
|
||||||
start=start,
|
|
||||||
end=end,
|
|
||||||
granularity="daily", # 使用日线数据以触发因子计算
|
|
||||||
)
|
|
||||||
|
|
||||||
refresh = force_refresh
|
refresh = force_refresh
|
||||||
if refresh is None:
|
if refresh is None:
|
||||||
refresh = get_config().force_refresh
|
refresh = get_config().force_refresh
|
||||||
|
|
||||||
if auto_fetch:
|
if auto_fetch:
|
||||||
# 使用 run_ingestion 来确保数据和因子都被更新
|
# 先执行增量数据更新
|
||||||
if progress_hook:
|
ensure_data_coverage(
|
||||||
progress_hook("开始更新数据和计算因子...", 0.0)
|
start,
|
||||||
|
end,
|
||||||
|
force=refresh,
|
||||||
|
progress_hook=progress_hook,
|
||||||
|
)
|
||||||
|
|
||||||
run_ingestion(job, include_limits=True)
|
# 然后执行因子计算
|
||||||
|
if progress_hook:
|
||||||
|
progress_hook("开始计算因子...", 0.8)
|
||||||
|
|
||||||
|
from app.features.factors import compute_factor_range
|
||||||
|
try:
|
||||||
|
compute_factor_range(start, end, skip_existing=not refresh)
|
||||||
|
LOGGER.info("因子计算完成", extra={"stage": "factor_compute"})
|
||||||
|
except Exception as e:
|
||||||
|
LOGGER.error("因子计算失败: %s", str(e), extra={"stage": "factor_compute"})
|
||||||
|
raise
|
||||||
|
|
||||||
coverage = collect_data_coverage(start, end)
|
coverage = collect_data_coverage(start, end)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user