...
This commit is contained in:
parent
9ff088bf6b
commit
0f7b7a12c1
@ -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시간 뒤에 다시 체크하도록 긴 지연시간 부여
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user