Files
sanguo_vnpy_v2/scripts/data_platform/ak_stock_wrapper.ps1
T

37 lines
2.8 KiB
PowerShell

# ak_stock_wrapper.ps1 — sanguo-ak-weekly schtask wrapper (weekly 周六03:00 akshare per-stock 慢)
# --force 全量刷新; 顺序=gdhs,top_holders,financial_abstract,share_capital (09-27 审计R1: share_capital 次新股
# KeyError 群最大最险挪最后, 防其(网络类)熔断连坐 fa/top_holders; 形状类失败已豁免断路器 b34ee53;
# 2026-09-12 移除 northbound: EM 沪深港通个股持股 2024-08 后已全量下线,
# 每周六 2883 单位全空跑纯烧时——北向改 HKEX 官方渠道, 见融合 spec §20.4);
# 2026-09-16 financial_abstract 从 ak-eod 每日移入 (user-approved batch):
# sina 源每晚 5.5k 连发撞限流 (09-14/15 断路器 FATAL), 单发实测通;
# 季度频数据周更足够, 量级 -87% + 周六凌晨错峰);
# gdhs=股东户数 per-period 全市场单次 (09-02 入列, 披露守卫>90天季度末, marker 去重无新期零网络)
# margin 回补兜底 (2026-09-12 §20): nightly T-2~T 窗漏的旧缺口每周六
# TMC gapsonly 早停补齐 (连续5完整日即停, 分钟级); 全史主力走
# --margin-backfill-ps (一次性, 另案执行); 退市史=--margin-backfill 慢通道慎用
# 因子 P1 三新域 (2026-09-22 §20.13, 独立命令不带 --force — marker 幂等增量):
# pledge_ratio 中登周报周五快照 (周六班拉昨日周五; 未发布→failed 不写
# marker 次周自愈) + pledge_detail 股东级明细月桶全量快照 (每月首班落盘)
# + research_report 研报共识周窗 (reportapi 直连, anchor=昨日周五窗收口)。
# --start 定在源头/回填边界: pledge 族 20210108, 研报 20210701 (factor 窗)。
$env:http_proxy = ''
$env:https_proxy = ''
$env:all_proxy = ''
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 "ak_stock_$ts.txt"
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types gdhs,top_holders,financial_abstract,share_capital --force *>> $log
$rc1 = $LASTEXITCODE
$bfLog = Join-Path $logDir "margin_backfill_$ts.txt"
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --margin-backfill-gaps *>> $bfLog
$rc2 = $LASTEXITCODE
$p1Log = Join-Path $logDir "ak_pledge_report_$ts.txt"
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types pledge_ratio,pledge_detail --start 20210108 *>> $p1Log
$rc3 = $LASTEXITCODE
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types research_report --start 20210701 *>> $p1Log
$rc4 = $LASTEXITCODE
if ($rc1 -ne 0 -or $rc2 -ne 0 -or $rc3 -ne 0 -or $rc4 -ne 0) { exit 1 } else { exit 0 }