This commit is contained in:
lun_admin 2026-04-06 09:13:05 +09:00
parent e28a2d2b14
commit ae3295c3e3
2 changed files with 30 additions and 23 deletions

View File

@ -3,5 +3,5 @@ object Defines {
var LLM_PORT = 8080 var LLM_PORT = 8080
var EMBEDDING_PORT = 8081 var EMBEDDING_PORT = 8081
val AUTOSELL = true val AUTOSELL = true
val BLACKLISTEDSTOCKCODES = listOf<String>("034220") val BLACKLISTEDSTOCKCODES = listOf<String>()
} }

View File

@ -375,6 +375,7 @@ object AutoTradingManager {
suspend fun sellingAfterMarketOnePrice(tradeService: KisTradeService,balance : UnifiedBalance,marketCode : String = "Y") { suspend fun sellingAfterMarketOnePrice(tradeService: KisTradeService,balance : UnifiedBalance,marketCode : String = "Y") {
println("sellingAfterMarketOnePrice") println("sellingAfterMarketOnePrice")
if (true) return
balance.holdings.forEach { holding -> balance.holdings.forEach { holding ->
if (BLACKLISTEDSTOCKCODES.contains(holding.code)){ if (BLACKLISTEDSTOCKCODES.contains(holding.code)){
println("❌ 차단 처리된 주식 : ${holding.name}") println("❌ 차단 처리된 주식 : ${holding.name}")
@ -441,19 +442,19 @@ object AutoTradingManager {
) )
} else { } else {
if (holding != null && holding.quantity.toInt() > 0 && holding.availOrderCount.toInt() > 0 && holding.profitRate.toDouble() > KisSession.config.SELL_PROFIT) { if (holding != null && holding.quantity.toInt() > 0 && holding.availOrderCount.toInt() > 0 && holding.profitRate.toDouble() > KisSession.config.SELL_PROFIT) {
println("${holding.name} - 매수 : ${holding.avgPrice} - 현재 : ${holding.currentPrice} ") // println("${holding.name} - 매수 : ${holding.avgPrice} - 현재 : ${holding.currentPrice} ")
// 3. 기존 목표가(targetPrice)로 다시 매도 주문 전송 // 3. 기존 목표가(targetPrice)로 다시 매도 주문 전송
var targetPrice = holding.currentPrice.toDouble() var targetPrice = holding.currentPrice.toDouble()
val now = LocalTime.now() val now = LocalTime.now()
val currentMinute = now.minute val currentMinute = now.minute
var isBefore930 = false var isBefore930 = false
if (now.hour == 9 && currentMinute < 30) { // if (now.hour == 9 && currentMinute < 30) {
targetPrice = targetPrice // targetPrice = targetPrice
isBefore930 = true // isBefore930 = true
} else { // } else {
targetPrice = MarketUtil.roundToTickSize(targetPrice + MarketUtil.getTickSize(targetPrice)) targetPrice = MarketUtil.roundToTickSize(targetPrice + MarketUtil.getTickSize(targetPrice))
} // }
println("🔄 [재주문] ${holding.name} (${holding.code}) 매도 목표 ${targetPrice} 미체결 매도 건 재주문 시도") println("🔄 [재주문] ${holding.name} (${holding.code}) 매도 목표 ${targetPrice} 미체결 매도 건 재주문 시도")
tradeService.postOrder( tradeService.postOrder(
stockCode = holding.code, stockCode = holding.code,
@ -540,6 +541,12 @@ object AutoTradingManager {
println("🚀 [AutoTrading] 발굴 루프 시작: ${LocalDateTime.now()}") println("🚀 [AutoTrading] 발굴 루프 시작: ${LocalDateTime.now()}")
while (isActive) { while (isActive) {
try { try {
listOf<String>("Y","X").forEach { code ->
KisTradeService.fetchIntegratedBalance(code).getOrNull()?.let {
sellingAfterMarketOnePrice(KisTradeService, it, code)
}
delay(1000)
}
now = LocalTime.now(ZoneId.of("Asia/Seoul")) now = LocalTime.now(ZoneId.of("Asia/Seoul"))
currentTimeMillis = System.currentTimeMillis() currentTimeMillis = System.currentTimeMillis()
lastTickTime.set(System.currentTimeMillis()) // 생존 신고 lastTickTime.set(System.currentTimeMillis()) // 생존 신고
@ -633,12 +640,12 @@ object AutoTradingManager {
if (AUTOSELL) balance?.let { resumePendingSellOrders(KisTradeService, it) } if (AUTOSELL) balance?.let { resumePendingSellOrders(KisTradeService, it) }
return balance return balance
} else { } else {
listOf<String>("Y","X").forEach { code -> // listOf<String>("Y","X").forEach { code ->
KisTradeService.fetchIntegratedBalance(code).getOrNull()?.let { // KisTradeService.fetchIntegratedBalance(code).getOrNull()?.let {
sellingAfterMarketOnePrice(KisTradeService, it, code) // sellingAfterMarketOnePrice(KisTradeService, it, code)
} // }
delay(1000) // delay(1000)
} // }
} }
return null return null
} }
@ -725,16 +732,16 @@ object AutoTradingManager {
} }
} }
else if((now.hour == 16 || now.hour == 17) && (currentMinute % 10 == 3 || currentMinute % 10 == 9)) { else if((now.hour == 16 || now.hour == 17) && (currentMinute % 10 == 3 || currentMinute % 10 == 9)) {
if (lastForceCheckMinute != currentMinute) { // if (lastForceCheckMinute != currentMinute) {
TradingLogStore.addAnalyzer( // TradingLogStore.addAnalyzer(
" - ", // " - ",
" - ", // " - ",
"⏰ [강제 스케줄 실행] 오후 ${now.hour}${currentMinute}분 - 보유주식 시간외 단일가 또는 대체마켓 체크를 시작합니다.", // "⏰ [강제 스케줄 실행] 오후 ${now.hour}시 ${currentMinute}분 - 보유주식 시간외 단일가 또는 대체마켓 체크를 시작합니다.",
true // true
) // )
checkBalance(false) // checkBalance(false)
lastForceCheckMinute = currentMinute // 실행 완료 기록 // lastForceCheckMinute = currentMinute // 실행 완료 기록
} // }
} }
} }