From 30ab7bbecf2d7b0bac577ae6ca69fad95c5749f2 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Mon, 10 Aug 2026 10:15:13 +0900 Subject: [PATCH] .. --- src/main/kotlin/service/AutoTradingManager.kt | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/service/AutoTradingManager.kt b/src/main/kotlin/service/AutoTradingManager.kt index 9e578e5..4572291 100644 --- a/src/main/kotlin/service/AutoTradingManager.kt +++ b/src/main/kotlin/service/AutoTradingManager.kt @@ -272,32 +272,30 @@ object AutoTradingManager { MarketUtil.roundToTickSize(basePrice * (1 + effectiveProfitRate / 100.0)) val calculatedStop = MarketUtil.roundToTickSize(basePrice * (1 + sRate / 100.0)) val inputQty = orderQty.replace(",", "").toIntOrNull() ?: 0 - - DatabaseFactory.saveAutoTrade( - AutoTradeItem( - orderNo = realOrderNo, - code = stockCode, - name = stockName, - quantity = inputQty, - profitRate = effectiveProfitRate, - stopLossRate = sRate, - targetPrice = calculatedTarget, - stopLossPrice = calculatedStop, - status = "PENDING_BUY", - isDomestic = true - ) - ) - - TradingReportManager.recordTradeDecision( - orderNo = realOrderNo, - stockCode = stockCode, - stockName = stockName, - isBuy = true, - orderQty = inputQty, - reason = decision.reason ?: "", // AI 이유 - decision = decision // AI 객체 통째로 전달 - ) if (!hasCode) { + DatabaseFactory.saveAutoTrade( + AutoTradeItem( + orderNo = realOrderNo, + code = stockCode, + name = stockName, + quantity = inputQty, + profitRate = effectiveProfitRate, + stopLossRate = sRate, + targetPrice = calculatedTarget, + stopLossPrice = calculatedStop, + status = "PENDING_BUY", + isDomestic = true + ) + ) + TradingReportManager.recordTradeDecision( + orderNo = realOrderNo, + stockCode = stockCode, + stockName = stockName, + isBuy = true, + orderQty = inputQty, + reason = decision.reason ?: "", // AI 이유 + decision = decision // AI 객체 통째로 전달 + ) syncAndExecute(realOrderNo) } // 💡 [개선 3] 감시 설정 로그에도 등급 정보 노출 @@ -994,6 +992,7 @@ object AutoTradingManager { currentBalance?.getHoldings()?.map { if( it.quantity.toInt() > KisSession.tradeConfig.lowerAverageTargetCount && + it.profitRate.toDouble() < 0.0 && it.profitRate.toDouble() < (abs(KisSession.tradeConfig.lowerAverageMaxRate) * -1) && it.profitRate.toDouble() > (abs(KisSession.tradeConfig.lowerAverageMinRate) * -1)) {