Files
sanguo_vnpy_v2/scripts/data_platform/index_monthly_wrapper.ps1
T
claude_dev 66a2c9e9ce feat(data): 中证指数日线点位修股票/指数同名碰撞 + 行业治偏差 section 名校正/增量接线
行情(修碰撞): 新 sina_index_eod.py 拉 14 中证指数日线点位(000016/300/852/905/985/000928-937)
入 dbbardata exchange=SSE, 与 SZSE 同名股票分离(provider .XSHG→SSE 零改动命中)。sina 主源 +
腾讯兜底 5 个 sina 停 2016 的(000929/930/936/937/985); 东财两端点持续封 VPS。schtask sanguo-idx-eod
18:30 增量(busy_timeout 60s 防 bs_eod 撞锁)。策略03 行业 mavg30 不再读个股股价。

治偏差(行业): INDEX_SECTION_MAP section 名校正(中证800能源->中证能源等, 1208 公告 content 实证);
index_monthly_wrapper STEP0b 接进 --indices 000928-937 月度增量(闭合 G1+G2 一次性未接增量缺口)。
注: 宽基治偏差(000852/000905/000016 等)早已完成(prior b237c2d); 行业指数 csindex 无 PDF 调整
公告(数据埋 HTML content), was_removed 仍~0, content 解析待专项。
2026-07-28 21:54:46 +08:00

48 lines
3.1 KiB
PowerShell

# index_monthly_wrapper.ps1 — sanguo-index schtask wrapper (monthly 16号 19:50 成份股刷新)
# STEP0: parse_csindex_announce (csindex 调整公告 -> announce_union, 治幸存者偏差全集, 2026-07-23 新增)
# STEP1: index_const_hist_download --parts A B (深证 A adjust_cni + 中证 B snapshot) akshare parquet 刷新
# STEP2: migrate_constituent 重建 staging (baostock _old 全集 + 深证 union + 中证 announce_union 全集)
# STEP3: merge_constituent staging -> constituent_unified (幂等 DROP+CREATE)
# 不碰 baostock online (全集已在 _old, migrate 读它); 不跑 C 新浪 (baostock 权威)
# STEP0 失败不阻塞 (csindex 网络抖动时 migrate 回退 snapshot, 治偏差降级但 pipeline 不死)
$env:http_proxy = ''
$env:https_proxy = ''
$env:all_proxy = ''
$env:PYTHONIOENCODING = 'utf-8'
$env:INDEX_HIST_OUT_DIR = 'C:\sanguo_vnpy_v2\data\index_const_hist'
$env:CSINDEX_CACHE = 'C:\sanguo_vnpy_v2\data\csindex_raw'
Set-Location C:\sanguo_vnpy_v2
$ts = Get-Date -Format 'yyyyMMdd_HHmmss'
$logDir = 'C:\sanguo_vnpy_v2\data\migration_logs'
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir -Force | Out-Null }
$log = Join-Path $logDir "index_monthly_$ts.txt"
$py = 'C:\Python310\python.exe'
$dir = 'C:\sanguo_vnpy_v2\scripts\data_platform'
"[$ts] STEP0 parse_csindex_announce --only both (csindex 公告 -> announce_union, 治偏差全集)" | Out-File $log -Encoding UTF8
& $py -X utf8 "$dir\parse_csindex_announce.py" --only both *>> $log
"[$ts] STEP0 done exit=$LASTEXITCODE (失败不阻塞, migrate 回退 snapshot)" | Out-File $log -Append -Encoding UTF8
# STEP0b: 中证一级行业指数系列 (000928-000937) 治偏差 - 独立第二次调用
# 原因: main() 里 --indices 与 --only 互斥 (line ~683 早 return), 必须独立调用。
# 不加 --max-notices-per-index: process_generic_index 每月从零重建 announce_union, 需保 was_removed 全历史。
# 失败不阻塞 (旧 parquet 兜底, migrate 用现存 announce_union)。
"[$ts] STEP0b parse_csindex_announce --indices 000928..000937 (中证行业指数系列, 独立调用)" | Out-File $log -Append -Encoding UTF8
& $py -X utf8 "$dir\parse_csindex_announce.py" --indices 000928,000929,000930,000931,000932,000933,000934,000935,000936,000937 *>> $log
"[$ts] STEP0b done exit=$LASTEXITCODE (失败不阻塞, 旧 parquet 兜底)" | Out-File $log -Append -Encoding UTF8
"[$ts] STEP1 index_const_hist_download --parts A B (深证 adjust + 中证 snapshot)" | Out-File $log -Append -Encoding UTF8
& $py -X utf8 "$dir\index_const_hist_download.py" --parts A B *>> $log
"[$ts] STEP1 done exit=$LASTEXITCODE" | Out-File $log -Append -Encoding UTF8
"[$ts] STEP2 migrate_constituent (rebuild staging from _old + parquet + announce_union)" | Out-File $log -Append -Encoding UTF8
& $py -X utf8 "$dir\migrate_constituent.py" *>> $log
"[$ts] STEP2 done exit=$LASTEXITCODE" | Out-File $log -Append -Encoding UTF8
"[$ts] STEP3 merge_constituent (staging -> constituent_unified, idempotent)" | Out-File $log -Append -Encoding UTF8
& $py -X utf8 "$dir\merge_constituent.py" *>> $log
$final = $LASTEXITCODE
"[$ts] STEP3 done exit=$final" | Out-File $log -Append -Encoding UTF8
exit $final