Files
Stock-trading-programming/scripts/setup_scheduler.ps1
T

40 lines
2.0 KiB
PowerShell
Raw Normal View History

# StockBot 작업 스케줄러 등록 (전체 재등록용)
# 실행: powershell -ExecutionPolicy Bypass -File scripts\setup_scheduler.ps1
$PROJECT = "C:\Users\whdwo\OneDrive\바탕 화면\stockbot_v3"
$weekdays = @(
[DayOfWeek]::Monday, [DayOfWeek]::Tuesday, [DayOfWeek]::Wednesday,
[DayOfWeek]::Thursday, [DayOfWeek]::Friday
)
function Register-StockTask($name, $time, $script, $limitMin) {
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek $weekdays -At $time
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NonInteractive -ExecutionPolicy Bypass -File `"$PROJECT\scripts\$script`"" `
-WorkingDirectory $PROJECT
$settings = New-ScheduledTaskSettingsSet `
-ExecutionTimeLimit (New-TimeSpan -Minutes $limitMin) `
-StartWhenAvailable
Register-ScheduledTask -TaskName $name -TaskPath "\StockBot\" `
-Trigger $trigger -Action $action -Settings $settings -RunLevel Limited -Force
Write-Host "[OK] $name 등록 완료 (평일 $time)" -ForegroundColor Green
}
# ── 4개 태스크 등록 ──────────────────────────────────────────────────────────
# 07:55 claude /start-bot → Python 봇 백그라운드 시작
Register-StockTask "StockBot_Bot" "07:55" "run_bot.ps1" 10
# 08:15 claude /morning → 뉴스+KIS 수집 → daily_context.json
Register-StockTask "StockBot_Morning" "08:15" "run_morning.ps1" 20
# 11:20 claude /midday → 장중 스냅샷 → midday_context.json → 점심 세션 시작
Register-StockTask "StockBot_Midday" "11:20" "run_midday.ps1" 20
# 15:30 claude /evening → 결과 분석 → 리포트 → Discord
Register-StockTask "StockBot_Evening" "15:30" "run_evening.ps1" 30
Write-Host ""
Write-Host "등록된 작업:" -ForegroundColor Cyan
Get-ScheduledTask -TaskPath "\StockBot\" | Format-Table TaskName, State