...
This commit is contained in:
parent
e28a2d2b14
commit
ae3295c3e3
@ -3,5 +3,5 @@ object Defines {
|
||||
var LLM_PORT = 8080
|
||||
var EMBEDDING_PORT = 8081
|
||||
val AUTOSELL = true
|
||||
val BLACKLISTEDSTOCKCODES = listOf<String>("034220")
|
||||
val BLACKLISTEDSTOCKCODES = listOf<String>()
|
||||
}
|
||||
@ -375,6 +375,7 @@ object AutoTradingManager {
|
||||
|
||||
suspend fun sellingAfterMarketOnePrice(tradeService: KisTradeService,balance : UnifiedBalance,marketCode : String = "Y") {
|
||||
println("sellingAfterMarketOnePrice")
|
||||
if (true) return
|
||||
balance.holdings.forEach { holding ->
|
||||
if (BLACKLISTEDSTOCKCODES.contains(holding.code)){
|
||||
println("❌ 차단 처리된 주식 : ${holding.name}")
|
||||
@ -441,19 +442,19 @@ object AutoTradingManager {
|
||||
)
|
||||
} else {
|
||||
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)로 다시 매도 주문 전송
|
||||
var targetPrice = holding.currentPrice.toDouble()
|
||||
val now = LocalTime.now()
|
||||
val currentMinute = now.minute
|
||||
var isBefore930 = false
|
||||
if (now.hour == 9 && currentMinute < 30) {
|
||||
targetPrice = targetPrice
|
||||
isBefore930 = true
|
||||
} else {
|
||||
// if (now.hour == 9 && currentMinute < 30) {
|
||||
// targetPrice = targetPrice
|
||||
// isBefore930 = true
|
||||
// } else {
|
||||
targetPrice = MarketUtil.roundToTickSize(targetPrice + MarketUtil.getTickSize(targetPrice))
|
||||
}
|
||||
// }
|
||||
println("🔄 [재주문] ${holding.name} (${holding.code}) 매도 목표 ${targetPrice} 미체결 매도 건 재주문 시도")
|
||||
tradeService.postOrder(
|
||||
stockCode = holding.code,
|
||||
@ -540,6 +541,12 @@ object AutoTradingManager {
|
||||
println("🚀 [AutoTrading] 발굴 루프 시작: ${LocalDateTime.now()}")
|
||||
while (isActive) {
|
||||
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"))
|
||||
currentTimeMillis = System.currentTimeMillis()
|
||||
lastTickTime.set(System.currentTimeMillis()) // 생존 신고
|
||||
@ -633,12 +640,12 @@ object AutoTradingManager {
|
||||
if (AUTOSELL) balance?.let { resumePendingSellOrders(KisTradeService, it) }
|
||||
return balance
|
||||
} else {
|
||||
listOf<String>("Y","X").forEach { code ->
|
||||
KisTradeService.fetchIntegratedBalance(code).getOrNull()?.let {
|
||||
sellingAfterMarketOnePrice(KisTradeService, it, code)
|
||||
}
|
||||
delay(1000)
|
||||
}
|
||||
// listOf<String>("Y","X").forEach { code ->
|
||||
// KisTradeService.fetchIntegratedBalance(code).getOrNull()?.let {
|
||||
// sellingAfterMarketOnePrice(KisTradeService, it, code)
|
||||
// }
|
||||
// delay(1000)
|
||||
// }
|
||||
}
|
||||
return null
|
||||
}
|
||||
@ -725,16 +732,16 @@ object AutoTradingManager {
|
||||
}
|
||||
}
|
||||
else if((now.hour == 16 || now.hour == 17) && (currentMinute % 10 == 3 || currentMinute % 10 == 9)) {
|
||||
if (lastForceCheckMinute != currentMinute) {
|
||||
TradingLogStore.addAnalyzer(
|
||||
" - ",
|
||||
" - ",
|
||||
"⏰ [강제 스케줄 실행] 오후 ${now.hour}시 ${currentMinute}분 - 보유주식 시간외 단일가 또는 대체마켓 체크를 시작합니다.",
|
||||
true
|
||||
)
|
||||
checkBalance(false)
|
||||
lastForceCheckMinute = currentMinute // 실행 완료 기록
|
||||
}
|
||||
// if (lastForceCheckMinute != currentMinute) {
|
||||
// TradingLogStore.addAnalyzer(
|
||||
// " - ",
|
||||
// " - ",
|
||||
// "⏰ [강제 스케줄 실행] 오후 ${now.hour}시 ${currentMinute}분 - 보유주식 시간외 단일가 또는 대체마켓 체크를 시작합니다.",
|
||||
// true
|
||||
// )
|
||||
// checkBalance(false)
|
||||
// lastForceCheckMinute = currentMinute // 실행 완료 기록
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user