65 lines
4.6 KiB
PowerShell
65 lines
4.6 KiB
PowerShell
# ak_events_wrapper.ps1 — sanguo-ak-events schtask wrapper (daily 19:30 akshare 事件类 per-date 当日)
|
|
# dragon_tiger/block_trade/restricted/zt_pool 三件套/新浪资金流×2/同花顺行业概念/雪球热度/新浪行业对账 --start today --end today;
|
|
# per-date 每类1 unit 快; zt_pool 系 (2026-09-02 双机实测 push2ex 集群稳定) 供情绪/打板因子;
|
|
# hot_rank (东财人气榜) 已于 2026-09-04 挂载进 --types (fetcher/注册早已就位);
|
|
# 新浪资金流+同花顺榜 (2026-09-02 用户批 A 档: 东财 push2 墙死后免费无墙替代, 秒级零限流)
|
|
# margin_sse 单独拆出 (2026-09-02 巡查+用户批准): SSE 融资融券 T+1 供应,当晚拉当天→空响应
|
|
# akshare Length mismatch 崩(07-22 起 43 天慢性失血,已 --force 回补 0722~0901);
|
|
# 2026-09-16 window fix (user-approved batch): T-1~T still guarantees one
|
|
# guaranteed-empty T-day failed EVERY night (EM SSE DATE view serves T+1).
|
|
# Now T-2~T-1 (all settled by run time): every unit green, retry-in-window
|
|
# keeps self-heal (missed T-1 becomes T-2 next night).
|
|
# hot_rank 2026-09-04 拍板挂载 (墙测量5轮收官: emappdata 夜间开窗, 22:28 实测 OK;
|
|
# 19:30 档失败零连带——单 unit 失败不触断路器, 不写不标, 次夜自动重试)
|
|
param([switch]$Force)
|
|
# time guard (2026-09-04, user approved): pre-market runs save LAST close state
|
|
# under today's filename + marker locks out the real 19:30 pull (hit twice:
|
|
# 09-02 08:08, 09-04 08:00). Refuse outside 19:00-23:59 unless -Force.
|
|
$guardHour = [int](Get-Date -Format HH)
|
|
if (-not $Force -and $guardHour -lt 19) {
|
|
$logDir = 'C:\sanguo_vnpy_v2\data\migration_logs'
|
|
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir -Force | Out-Null }
|
|
$msg = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') REFUSED: ak-events window is 19:00-23:59, now outside. Use -Force to override."
|
|
Add-Content -Path (Join-Path $logDir 'ak_events_guard.log') -Value $msg
|
|
Write-Output $msg
|
|
exit 1
|
|
}
|
|
$env:http_proxy = ''
|
|
$env:https_proxy = ''
|
|
$env:all_proxy = ''
|
|
Set-Location C:\sanguo_vnpy_v2
|
|
$today = Get-Date -Format yyyyMMdd
|
|
$yesterday = (Get-Date).AddDays(-1).ToString('yyyyMMdd')
|
|
$day3 = (Get-Date).AddDays(-2).ToString('yyyyMMdd')
|
|
$day4 = (Get-Date).AddDays(-3).ToString('yyyyMMdd')
|
|
$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_events_$ts.txt"
|
|
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types dragon_tiger,block_trade,restricted,zt_pool,zt_pool_zbgc,zt_pool_dtgc,fund_flow_industry,fund_flow_concept,ths_industry,ths_concept,xueqiu_hot,sina_sector,hot_rank,sw_industry --start $today --end $today *>> $log
|
|
$rc1 = $LASTEXITCODE
|
|
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types margin_sse --start $day3 --end $yesterday *>> $log
|
|
$rc2 = $LASTEXITCODE
|
|
# margin (four-domain add 2026-09-12, spec 20; window fix 2026-09-13):
|
|
# verified by data spot-check: DATE view on unsettled evening = SH-only 2000,
|
|
# settled next trading evening = full market 4443 (09-08 measured). Old T-2..T
|
|
# window wrote SH-partial for day T + marker -> permanent deep hole (0911 case).
|
|
# New: T-3..T-1 (all settled by run time), weekdays only. Saturday gaps
|
|
# backfill stays as safety net. See spec 20.7.
|
|
$dow = [int](Get-Date).DayOfWeek
|
|
if ($dow -ge 1 -and $dow -le 5) {
|
|
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types margin --start $day4 --end $yesterday *>> $log
|
|
$rc3 = $LASTEXITCODE
|
|
} else { $rc3 = 0 }
|
|
# dragon_tiger_seats (2026-09-12 四域扩展): 当日上榜股×买卖top5席位 (~136发/夜
|
|
# ~3分钟); T-1~T 窗防席位晚间延迟上线; 增量域不回补.
|
|
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types dragon_tiger_seats --start $yesterday --end $today *>> $log
|
|
$rc4 = $LASTEXITCODE
|
|
# 北向双域 (2026-09-12 四域扩展, spec §20.4): nb_daily=HKEX日统计js(T-1~T,
|
|
# 非交易日404写空+done); nb_hold=季度快照检查器(每晚4 POST双日自证,内容不变不写)
|
|
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types nb_daily --start $yesterday --end $today *>> $log
|
|
$rc5 = $LASTEXITCODE
|
|
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\data_platform\akshare_static_download.py --types nb_hold *>> $log
|
|
$rc6 = $LASTEXITCODE
|
|
if ($rc1 -ne 0 -or $rc2 -ne 0 -or $rc3 -ne 0 -or $rc4 -ne 0 -or $rc5 -ne 0 -or $rc6 -ne 0) { exit 1 } else { exit 0 }
|