This commit is contained in:
lun_admin 2026-06-03 13:27:05 +09:00
parent 91b616e127
commit d57f1698af
2 changed files with 11 additions and 9 deletions

View File

@ -86,7 +86,7 @@ object AutoTradingManager {
val now = LocalTime.now(ZoneId.of("Asia/Seoul")) val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
val nowDate = LocalDate.now(seoulZone) val nowDate = LocalDate.now(seoulZone)
var checkTime = 60_000 * 3L var checkTime = 60_000 * 3L
val isTradingDay = nowDate.dayOfWeek.value in 1..5 val isTradingDay = MarketUtil.canTradeToday()
if (isTradingDay && now.isAfter(KisSession.startTime()) && now.isBefore(KisSession.endTime()) && !shouldShowFullWindow) { if (isTradingDay && now.isAfter(KisSession.startTime()) && now.isBefore(KisSession.endTime()) && !shouldShowFullWindow) {
shouldShowFullWindow = true shouldShowFullWindow = true
SystemSleepPreventer.wakeDisplay() SystemSleepPreventer.wakeDisplay()
@ -951,7 +951,6 @@ object AutoTradingManager {
if (reanalysisList.isNotEmpty()) { if (reanalysisList.isNotEmpty()) {
candidates.addAll(reanalysisList) candidates.addAll(reanalysisList)
} }
candidates.clear()///물타기
reanalysisList.clear() reanalysisList.clear()
if (KisSession.tradeConfig.lowerAveragePrice) { if (KisSession.tradeConfig.lowerAveragePrice) {
currentBalance?.getHoldings()?.map { currentBalance?.getHoldings()?.map {

View File

@ -6,7 +6,7 @@ import java.time.ZoneId
object MarketUtil { object MarketUtil {
private var isHolidayCached: Boolean? = null // 하루 한 번만 체크하기 위한 캐시 private var isHolidayCached: Boolean? = null // 하루 한 번만 체크하기 위한 캐시
var holiDays = hashMapOf<String, Boolean>()
suspend fun canTradeToday(): Boolean { suspend fun canTradeToday(): Boolean {
val seoulZone = java.time.ZoneId.of("Asia/Seoul") val seoulZone = java.time.ZoneId.of("Asia/Seoul")
val now = java.time.ZonedDateTime.now(seoulZone) val now = java.time.ZonedDateTime.now(seoulZone)
@ -16,11 +16,13 @@ object MarketUtil {
val dayOfWeek = now.dayOfWeek.value val dayOfWeek = now.dayOfWeek.value
if (dayOfWeek >= 6) return false if (dayOfWeek >= 6) return false
// 1. 주말 체크 (토, 일) // 1. 주말 체크 (토, 일)
val cachedHoliday = DatabaseFactory.getHoliday(todayStr) try {
if (cachedHoliday != null) { if (holiDays.contains(todayStr)) {
println("📂 [DB Cache] 오늘($todayStr)의 휴장 여부를 DB에서 로드했습니다: ${if(cachedHoliday) "휴장" else "영업일"}") println("📂 [DB Cache] 오늘($todayStr)의 휴장 여부를 DB에서 로드했습니다: ${if(holiDays.get(todayStr) == true) "휴장" else "영업일"}")
return !cachedHoliday return holiDays.get(todayStr) == false
} }
} catch (e: Exception) {e.printStackTrace()}
// 3. DB에 없으면 API 호출 // 3. DB에 없으면 API 호출
return try { return try {
@ -28,11 +30,12 @@ object MarketUtil {
val isHoliday = result.getOrDefault(true) val isHoliday = result.getOrDefault(true)
// 결과를 DB에 저장하여 다음 실행 시 재사용 // 결과를 DB에 저장하여 다음 실행 시 재사용
DatabaseFactory.saveHoliday(todayStr, isHoliday) holiDays.put(todayStr, isHoliday)
println("🌐 [API Call] 오늘($todayStr)의 휴장 여부를 새로 조회하여 DB에 저장했습니다.") println("🌐 [API Call] 오늘($todayStr)의 휴장 여부를 새로 조회하여 DB에 저장했습니다.")
!isHoliday !isHoliday
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace()
false false
} }
} }