From 0f7b7a12c1e575861cd33375c4383f9c9f462449 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Thu, 26 Mar 2026 15:40:46 +0900 Subject: [PATCH] ... --- src/main/kotlin/service/AutoTradingManager.kt | 15 ++++++++------- src/main/kotlin/ui/TradingDecisionLog.kt | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/service/AutoTradingManager.kt b/src/main/kotlin/service/AutoTradingManager.kt index 27b8d58..aa08ac1 100644 --- a/src/main/kotlin/service/AutoTradingManager.kt +++ b/src/main/kotlin/service/AutoTradingManager.kt @@ -449,7 +449,7 @@ object AutoTradingManager { var now = LocalTime.now(ZoneId.of("Asia/Seoul")) var currentTimeMillis = System.currentTimeMillis() var waitTime = 0.2 - val H16 = LocalTime.of(16, 0) + val H18 = LocalTime.of(18, 0) val H08M35 = LocalTime.of(8, 35) val H08M30 = LocalTime.of(8, 30) private fun runDiscoveryLoop(callback: TradingDecisionCallback) { @@ -461,10 +461,10 @@ object AutoTradingManager { currentTimeMillis = System.currentTimeMillis() lastTickTime.set(System.currentTimeMillis()) // 생존 신고 when { - now.isAfter(H16) || now.isBefore(H08M35) -> { + now.isAfter(H18) || now.isBefore(H08M35) -> { prepareMarketOpen(now) } - now.isBefore(H16) && now.isAfter(H08M35) -> { + now.isBefore(H18) && now.isAfter(H08M35) -> { waitTime = 0.2 if (now.isAfter(LocalTime.of(8, 0)) && now.isBefore(LocalTime.of(15, 30))) { if (!KisSession.isMarketTokenValid() || !KisSession.isTradeTokenValid()) { @@ -478,7 +478,7 @@ object AutoTradingManager { } withTimeout(CYCLE_TIMEOUT) { println("⏱️ [Cycle Start] ${LocalTime.now()}") - if (now.isAfter(H16)) { + if (now.isAfter(H18)) { executeClosingLiquidation(KisTradeService) } else { executeMarketLoop() @@ -506,22 +506,23 @@ object AutoTradingManager { } suspend fun prepareMarketOpen(now : LocalTime) { - if (now.isAfter(H16) || now.isBefore(H08M30)) { + if (now.isAfter(H18) || now.isBefore(H08M30)) { println("🌙 [System] 마감 시간 도달. 자원 정리 후 대기 모드(설정 화면)로 전환합니다.") onMarketClosed?.invoke() KisWebSocketManager.disconnect() BrowserManager.closeIfIdle(0) LlamaServerManager.stopAll() // AI 서버 완전 종료 TradingLogStore.clear() - // Main.kt에 설정 화면으로 가라고 신호 전송 + isSystemReadyToday = false + shouldShowFullWindow = false stopDiscovery() // 발굴 루프 완전 폭파 (내일 8시 30분에 다시 켜짐) } else if (now.isAfter(H08M30) && now.isBefore(H08M35) && !isSystemReadyToday) { if (MarketUtil.canTradeToday()) { + shouldShowFullWindow = true println("✅ [System] 오늘은 영업일입니다. 시스템을 가동합니다.") tryRefreshToken() // 토큰 갱신 및 화면 표시 신호(shouldShowFullWindow = true) } else { println("💤 [System] 오늘은 휴장일(또는 주말)입니다. 대기 모드를 유지합니다.") - isSystemReadyToday = false delay(3600_000) // 휴장일이면 1시간 뒤에 다시 체크하도록 긴 지연시간 부여 } } diff --git a/src/main/kotlin/ui/TradingDecisionLog.kt b/src/main/kotlin/ui/TradingDecisionLog.kt index 557a7d9..c9ddb89 100644 --- a/src/main/kotlin/ui/TradingDecisionLog.kt +++ b/src/main/kotlin/ui/TradingDecisionLog.kt @@ -154,7 +154,10 @@ fun TradingDecisionLog() { fontWeight = FontWeight.ExtraBold ) } - Text("신뢰도: ${log.confidence}%", fontSize = 11.sp) + when (log.decision) { + "BUY", "SELL", "HOLD" -> Text("신뢰도: ${log.confidence}%", fontSize = 11.sp) + } + Text("이유: ${log.reason}", fontSize = 12.sp, color = Color.DarkGray) } }