This commit is contained in:
lunaticbum 2026-06-09 14:16:18 +09:00
parent 075a085b92
commit affad2743e
2 changed files with 10 additions and 12 deletions

View File

@ -193,7 +193,7 @@ object KisWebSocketManager {
// AES 복호화 실행
val decryptedData = AesCrypto.decrypt(parts[3], aesKey, aesIv)
val dataRows = decryptedData.split("^")
println("🔔 복호화된 체결 통보: ${if (dataRows[4] == "01") {"매도"} else {"매수"}} ${dataRows[8]} ${dataRows[9]}${if(dataRows[13] == "01"){"체결"}else{"접수"} }")
println("🔔 복호화된 체결 통보: ${if (dataRows[4] == "01") {"매도"} else {"매수"}} ${dataRows[8]} ${dataRows[9]}${if(dataRows[13] == "2") {"체결"} else {"접수"} }")
// UI 콜백 호출 (종목코드, 체결량, 체결가, 주문번호, 체결여부)
onExecutionReceived?.invoke(

View File

@ -83,20 +83,18 @@ object AutoTradingManager {
fun startBackgroundScheduler() {
scope.launch {
while (isActive) {
val seoulZone = ZoneId.of("Asia/Seoul")
val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
val nowDate = LocalDate.now(seoulZone)
var checkTime = 60_000 * 3L
val isTradingDay = MarketUtil.canTradeToday()
if (isTradingDay && now.isAfter(KisSession.startTime()) && now.isBefore(KisSession.endTime()) && !shouldShowFullWindow) {
shouldShowFullWindow = true
SystemSleepPreventer.wakeDisplay()
} else if (now.isAfter(LocalTime.of(23, 50)) && now.isBefore(LocalTime.of(8, 0))) {
SystemSleepPreventer.sleepDisplay()
}
if (!isTradingDay) {
checkTime = 60_000 * 30L
// SystemSleepPreventer.wakeDisplay()
} else if ((now.isAfter(LocalTime.of(23, 50)) && now.isBefore(LocalTime.of(8, 0)))) {
// SystemSleepPreventer.sleepDisplay()
}
// if (!isTradingDay) {
// checkTime = 60_000 * 30L
// }
delay(checkTime) // 1분마다 체크
}
}
@ -244,7 +242,7 @@ object AutoTradingManager {
if (hasCode && oldTarget != null) {
var avgPrive = oldTarget.avgPrice.toDouble()
var qty = oldTarget.quantity.toDouble()
basePrice = avgPrive//((avgPrive * qty) + (decision.currentPrice * orderQty.toInt())).div(qty!!.toInt() + (orderQty.toInt()))
basePrice = avgPrive * 1.1//((avgPrive * qty) + (decision.currentPrice * orderQty.toInt())).div(qty!!.toInt() + (orderQty.toInt()))
println("물타기 ${avgPrive}, ${qty} ${basePrice}")
}
} catch (e:Exception) {e.printStackTrace()}
@ -850,7 +848,7 @@ object AutoTradingManager {
}
var currentBalance : UnifiedBalance? = null
private var lastFetchTime: Long = 0L // 마지막 성공 시간 (Millisecond)
private val FETCH_INTERVAL = 30 * 60 * 1000 // 30분을 밀리초로 환산 (1800000 ms)
private val FETCH_INTERVAL = 2 * 60 * 1000 // 30분을 밀리초로 환산 (1800000 ms)
suspend fun checkBalance() {
val currentTime = System.currentTimeMillis()
@ -865,7 +863,7 @@ object AutoTradingManager {
} else {
// 30분이 지나지 않았다면 기존에 저장된 currentBalance를 그대로 사용
println("30분이 지나지 않아 기존 잔고 데이터 유지 (남은 시간: ${(FETCH_INTERVAL - (currentTime - lastFetchTime)) / 1000}초)")
println("${(FETCH_INTERVAL / (1000 * 60))}분이 지나지 않아 기존 잔고 데이터 유지 (남은 시간: ${(FETCH_INTERVAL - (currentTime - lastFetchTime)) / 1000}초)")
}
if (KisSession.config.take_profit) currentBalance?.let { resumePendingSellOrders(KisTradeService, it) }
if (KisSession.tradeConfig.auto_cancel_pending_buy) { checkAndCancelPendingBuyOrders() }