...
This commit is contained in:
parent
f830163940
commit
7ce24cc631
@ -139,6 +139,10 @@ fun main() = application {
|
||||
} else {
|
||||
when (currentScreen) {
|
||||
AppScreen.Settings -> {
|
||||
AutoTradingManager.onMarketClosed = {
|
||||
println("프로그램 초기화 실행됨")
|
||||
currentScreen = AppScreen.Settings
|
||||
}
|
||||
SettingsScreen(
|
||||
onAuthSuccess = {
|
||||
|
||||
@ -146,6 +150,7 @@ fun main() = application {
|
||||
val config = KisSession.config
|
||||
AutoTradingManager.isSystemReadyToday = true
|
||||
AutoTradingManager.isSystemCleanedUpToday = false
|
||||
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
AutoTradingManager.startAutoDiscoveryLoop()
|
||||
KisWebSocketManager.onExecutionReceived = AutoTradingManager.onExecutionReceived
|
||||
|
||||
@ -403,6 +403,7 @@ object AutoTradingManager {
|
||||
var waitTime = 0.2
|
||||
val H16 = LocalTime.of(16, 0)
|
||||
val H08M50 = LocalTime.of(8, 50)
|
||||
val H08M30 = LocalTime.of(8, 30)
|
||||
private fun runDiscoveryLoop(tradeService: KisTradeService, callback: TradingDecisionCallback) {
|
||||
discoveryJob = scope.launch {
|
||||
println("🚀 [AutoTrading] 발굴 루프 시작: ${LocalDateTime.now()}")
|
||||
@ -412,14 +413,16 @@ object AutoTradingManager {
|
||||
currentTimeMillis = System.currentTimeMillis()
|
||||
lastTickTime.set(System.currentTimeMillis()) // 생존 신고
|
||||
// [수정] 16시 이후이거나 8시 30분 이전이면 모든 로직 중단 및 초기화
|
||||
if (now.isAfter(LocalTime.of(16, 0)) || now.isBefore(LocalTime.of(8, 30))) {
|
||||
if (now.isAfter(H16) || now.isBefore(H08M30)) {
|
||||
println("🌙 [System] 마감 시간 도달. 자원 정리 후 대기 모드(설정 화면)로 전환합니다.")
|
||||
SystemSleepPreventer.sleepDisplay() // 모니터 끄기
|
||||
onMarketClosed?.invoke()
|
||||
|
||||
|
||||
KisWebSocketManager.disconnect()
|
||||
BrowserManager.closeIfIdle(0)
|
||||
LlamaServerManager.stopAll() // AI 서버 완전 종료
|
||||
TradingLogStore.clear()
|
||||
onMarketClosed?.invoke() // Main.kt에 설정 화면으로 가라고 신호 전송
|
||||
// Main.kt에 설정 화면으로 가라고 신호 전송
|
||||
stopDiscovery() // 발굴 루프 완전 폭파 (내일 8시 30분에 다시 켜짐)
|
||||
return@launch
|
||||
}
|
||||
@ -703,6 +706,23 @@ object AutoTradingManager {
|
||||
discoveryJob?.cancel()
|
||||
discoveryJob = null
|
||||
println("🛑 [AutoTrading] 자동 발굴 중단됨")
|
||||
|
||||
scope.launch {
|
||||
onMarketClosed?.invoke()
|
||||
println("💤 대기 모드 진입... $5.0")
|
||||
val endWait = System.currentTimeMillis() + (5.0 * 60 * 1000L)
|
||||
BrowserManager.closeIfIdle(0) // 즉시 닫기
|
||||
while (System.currentTimeMillis() < endWait) {
|
||||
lastTickTime.set(System.currentTimeMillis()) // 대기 중에도 Watchdog에 생존 신고
|
||||
println("💤 대기 모드 상태 확인...")
|
||||
delay(if(5.0 > 3.0 ) 10000 else 1000)
|
||||
}
|
||||
KisWebSocketManager.disconnect()
|
||||
BrowserManager.closeIfIdle(0)
|
||||
LlamaServerManager.stopAll() // AI 서버 완전 종료
|
||||
TradingLogStore.clear()
|
||||
onMarketClosed?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
fun addStock(currentPrice : Double , technicalAnalyzer : TechnicalAnalyzer,stockName: String, stockCode: String, result: TradingDecisionCallback) {
|
||||
|
||||
@ -44,7 +44,7 @@ import service.SystemSleepPreventer
|
||||
fun SettingsScreen(onAuthSuccess: () -> Unit) {
|
||||
val scope = rememberCoroutineScope()
|
||||
var config by remember { mutableStateOf(KisSession.config) }
|
||||
var statusMessage by remember { mutableStateOf("정보를 입력하세요.") }
|
||||
var statusMessage by remember { mutableStateOf("프로그램 초기화") }
|
||||
|
||||
val authenticateAndStart: suspend () -> Unit = {
|
||||
var retryCount = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user