This commit is contained in:
2026-03-27 10:59:59 +09:00
parent 1479face39
commit f6bce36924
3 changed files with 150 additions and 39 deletions
+12 -23
View File
@@ -72,29 +72,18 @@ object AutoTradingManager {
var tradeToken by mutableStateOf(false)
var webSocketConnect by mutableStateOf(false)
var testFlag = false
fun startBackgroundScheduler() {
// scope.launch {
// while (isActive) {
// val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
//
// // 1. 오전 8시 30분 ~ 15시 30분 사이인지 확인
// if (now.isAfter(LocalTime.of(8, 30)) && now.isBefore(LocalTime.of(15, 30))) {
// // 2. 아직 오늘 시스템 준비가 안 되었고, 설정값이 있는 경우
// if (!isSystemReadyToday && KisSession.config.realAppKey.isNotEmpty()) {
// println("⏰ [Scheduler] 자동 실행 시간이 되어 인증을 시작합니다.")
// SystemSleepPreventer.wakeDisplay() //
//
// // 인증 및 토큰 갱신 시도
// val success = KisAuthService.refreshAllTokens() && KisTradeService.refreshWebsocketKey()
// if (success) {
// isSystemReadyToday = true
// startAutoDiscoveryLoop() // 자동 매매 루프 시작
// }
// }
// }
// delay(60_000) // 1분마다 체크
// }
// }
scope.launch {
while (isActive) {
val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
if (now.isAfter(H08M30) && now.isBefore(H18) && !shouldShowFullWindow) {
shouldShowFullWindow = true
SystemSleepPreventer.wakeDisplay()
}
delay(60_000 * 3) // 1분마다 체크
}
}
}
val globalCallback = { completeTradingDecision: TradingDecision?, isSuccess: Boolean ->
@@ -619,7 +608,7 @@ object AutoTradingManager {
}
}
(AutoTradingManager.now.isAfter(LocalTime.of(18, 0))) -> {
(AutoTradingManager.now.isAfter(LocalTime.of(18, 30))) -> {
try {
waitTime = 5.0
println("current SystemCleanedUpToday is $isSystemCleanedUpToday")