....
This commit is contained in:
parent
075a085b92
commit
affad2743e
@ -193,7 +193,7 @@ object KisWebSocketManager {
|
|||||||
// AES 복호화 실행
|
// AES 복호화 실행
|
||||||
val decryptedData = AesCrypto.decrypt(parts[3], aesKey, aesIv)
|
val decryptedData = AesCrypto.decrypt(parts[3], aesKey, aesIv)
|
||||||
val dataRows = decryptedData.split("^")
|
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 콜백 호출 (종목코드, 체결량, 체결가, 주문번호, 체결여부)
|
// UI 콜백 호출 (종목코드, 체결량, 체결가, 주문번호, 체결여부)
|
||||||
onExecutionReceived?.invoke(
|
onExecutionReceived?.invoke(
|
||||||
|
|||||||
@ -83,20 +83,18 @@ object AutoTradingManager {
|
|||||||
fun startBackgroundScheduler() {
|
fun startBackgroundScheduler() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
val seoulZone = ZoneId.of("Asia/Seoul")
|
|
||||||
val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
|
val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
|
||||||
val nowDate = LocalDate.now(seoulZone)
|
|
||||||
var checkTime = 60_000 * 3L
|
var checkTime = 60_000 * 3L
|
||||||
val isTradingDay = MarketUtil.canTradeToday()
|
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()
|
||||||
} else if (now.isAfter(LocalTime.of(23, 50)) && now.isBefore(LocalTime.of(8, 0))) {
|
} else if ((now.isAfter(LocalTime.of(23, 50)) && now.isBefore(LocalTime.of(8, 0)))) {
|
||||||
SystemSleepPreventer.sleepDisplay()
|
// SystemSleepPreventer.sleepDisplay()
|
||||||
}
|
|
||||||
if (!isTradingDay) {
|
|
||||||
checkTime = 60_000 * 30L
|
|
||||||
}
|
}
|
||||||
|
// if (!isTradingDay) {
|
||||||
|
// checkTime = 60_000 * 30L
|
||||||
|
// }
|
||||||
delay(checkTime) // 1분마다 체크
|
delay(checkTime) // 1분마다 체크
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +242,7 @@ object AutoTradingManager {
|
|||||||
if (hasCode && oldTarget != null) {
|
if (hasCode && oldTarget != null) {
|
||||||
var avgPrive = oldTarget.avgPrice.toDouble()
|
var avgPrive = oldTarget.avgPrice.toDouble()
|
||||||
var qty = oldTarget.quantity.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}")
|
println("물타기 ${avgPrive}, ${qty} ${basePrice}")
|
||||||
}
|
}
|
||||||
} catch (e:Exception) {e.printStackTrace()}
|
} catch (e:Exception) {e.printStackTrace()}
|
||||||
@ -850,7 +848,7 @@ object AutoTradingManager {
|
|||||||
}
|
}
|
||||||
var currentBalance : UnifiedBalance? = null
|
var currentBalance : UnifiedBalance? = null
|
||||||
private var lastFetchTime: Long = 0L // 마지막 성공 시간 (Millisecond)
|
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() {
|
suspend fun checkBalance() {
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
@ -865,7 +863,7 @@ object AutoTradingManager {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 30분이 지나지 않았다면 기존에 저장된 currentBalance를 그대로 사용
|
// 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.config.take_profit) currentBalance?.let { resumePendingSellOrders(KisTradeService, it) }
|
||||||
if (KisSession.tradeConfig.auto_cancel_pending_buy) { checkAndCancelPendingBuyOrders() }
|
if (KisSession.tradeConfig.auto_cancel_pending_buy) { checkAndCancelPendingBuyOrders() }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user