# index_monthly_wrapper.ps1 — sanguo-index schtask wrapper (monthly 16号 19:50 成份股刷新) # 1. index_const_hist_download 深证(A adjust_cni)+中证(B snapshot) akshare parquet 刷新(成份股随时间变) # 2. migrate_constituent 重建 staging(从 bs_index_constituent_old baostock 全集 + 深证/中证 parquet) # 3. merge_constituent staging -> constituent_unified (幂等 DROP+CREATE) # 不碰 baostock online(全集已在 _old, migrate 读它); 不跑 C 新浪(baostock 权威) $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' 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] STEP1 index_const_hist_download --parts A B (深证 adjust + 中证 snapshot)" | Out-File $log -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)" | 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