From 5e90ee39bc541ab6d20edd107ffbb6a185f75811 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Mon, 7 Sep 2026 14:18:23 +0900 Subject: [PATCH] ... --- src/main/kotlin/analyzer/TechnicalAnalyzer.kt | 5 +++-- src/main/kotlin/model/AppConfig.kt | 5 +++++ src/main/kotlin/service/AutoTradingManager.kt | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/analyzer/TechnicalAnalyzer.kt b/src/main/kotlin/analyzer/TechnicalAnalyzer.kt index 737609c..6cd5774 100644 --- a/src/main/kotlin/analyzer/TechnicalAnalyzer.kt +++ b/src/main/kotlin/analyzer/TechnicalAnalyzer.kt @@ -353,7 +353,7 @@ class TechnicalAnalyzer { // ๐ŸŒŸ 3. 3๊ฐœ ์ค‘ 2๊ฐœ ์ด์ƒ ๋งŒ์กฑ ์‹œ ๋ฐ˜๋“ฑ ์ž„๋ฐ•(Approaching)์œผ๋กœ ํŒ๋‹จ val passedConditions = listOf(isPriceDropped, isPastMinTime, isWithinMaxTime).count { it } - + //A. ์ง„์ž… ํ•˜๋ฝ๋ฅ  ๊ธฐ์ค€checkReboundApproaching 3๊ฐœ ์ค‘ 2๊ฐœ ๋งŒ์กฑ ์‹œ ํ†ต๊ณผ ๊ฐ€๊ฒฉ ํ•˜๋ฝ ์กฐ๊ฑด(isPriceDropped)์„ ํ•„์ˆ˜ ์กฐ๊ฑด(AND)์œผ๋กœ ๊ณ ์ • return passedConditions >= 2 } @@ -670,7 +670,8 @@ $standardizedScores val remainingDropRate = reboundStats.avgDropRate - currentDropRate // ๋ฐ”๋‹ฅ๊ถŒ ์ธ์ • ๋งˆ์ง„ (ATR ๊ธฐ๋ฐ˜) - val bottomMargin = currentAtr * 0.7 + //B. ๋ฐ”๋‹ฅ๊ถŒ ํŒ์ • ๋งˆ์ง„predictDropBottom currentAtr * 0.7 ์—ฌ์œ  ๋งˆ์ง„ ๋งˆ์ง„์„ ์ถ•์†Œ(currentAtr * 0.3)ํ•˜์—ฌ ์˜ˆ์ƒ ๋ฐ”๋‹ฅ์— ๋” ๊ทผ์ ‘ํ•ด์•ผ ์ธ์ • + val bottomMargin = currentAtr * 0.5 // ์ €์  ํ‰๊ท (smoothedBottom)๋„ ๋งˆ์ง€๋…ธ์„  ๊ณ„์‚ฐ์— ์ถ”๊ฐ€ ๊ฐ€์ค‘์น˜๋กœ ์„ž์–ด์คŒ์œผ๋กœ์จ ์ €์ ์— ๋” ๋ฐ€์ฐฉ์‹œํ‚ด val adjustedExtremeLow = (volatility.extremeLow + smoothedBottom) / 2.0 diff --git a/src/main/kotlin/model/AppConfig.kt b/src/main/kotlin/model/AppConfig.kt index 028925f..4edd5b8 100644 --- a/src/main/kotlin/model/AppConfig.kt +++ b/src/main/kotlin/model/AppConfig.kt @@ -360,4 +360,9 @@ object KisSession { fun isAvailBuyTime(now: LocalTime) : Boolean { return now.isBefore(endBuyTime()) && now.isAfter(startBuyTime()) } + + fun isMarketOpenTime(now: LocalTime) : Boolean { + return now.isBefore(LocalTime.of(15,30)) && now.isAfter(LocalTime.of(9,0)) + } + } \ No newline at end of file diff --git a/src/main/kotlin/service/AutoTradingManager.kt b/src/main/kotlin/service/AutoTradingManager.kt index 91ab9fb..1526644 100644 --- a/src/main/kotlin/service/AutoTradingManager.kt +++ b/src/main/kotlin/service/AutoTradingManager.kt @@ -242,7 +242,7 @@ object AutoTradingManager { TradingLogStore.addNotice("SYSTEM", "LIMIT", "์ตœ๋Œ€ ๋ณด์œ  ์ข…๋ชฉ ๋„๋‹ฌ๋กœ ์‹ ๊ทœ ๋งค์ˆ˜ ์ผ์‹œ ์ค‘๋‹จ") addToReanalysis(RankingStock(mksc_shrn_iscd = stockCode,hts_kor_isnm = stockName)) TradingLogStore.addWatchLog(decision,"WATCH","๋งค์ˆ˜ ์‹คํŒจ : ์ตœ๋Œ€ ๋ณด์œ  ์ข…๋ชฉ ๋„๋‹ฌ๋กœ ์‹ ๊ทœ ๋งค์ˆ˜ ์ผ์‹œ ์ค‘๋‹จ => ์žฌ๋ถ„์„ ๋Œ€๊ธฐ์—ด์— ์ถ”๊ฐ€") - } else if (KisSession.isAvailBuyTime(LocalTime.now())){ + } else if (KisSession.isAvailBuyTime(LocalTime.now()) || hasCode){ println("basePrice : $basePrice, oneTickLowerPrice : $oneTickLowerPrice, finalPrice : $finalPrice hasStocks : ${stockCode.contains(stockCode)}" ) var realOrderQty = orderQty KisTradeService.postOrder(stockCode, realOrderQty, finalPrice.toLong().toString(), isBuy = true) @@ -1028,7 +1028,7 @@ object AutoTradingManager { while (iterator.hasNext()) { totalCount-- val stock = iterator.next() - if (KisSession.isAvailBuyTime(now)) { + if (KisSession.isMarketOpenTime(now)) { if (BLACKLISTEDSTOCKCODES.contains(stock.code)) { println("โŒ ์ฐจ๋‹จ ์ฒ˜๋ฆฌ๋œ ์ฃผ์‹ : ${stock.name}") } else { @@ -1181,8 +1181,8 @@ object AutoTradingManager { val tempAnalyzer = TechnicalAnalyzer().apply { this.daily = dailyData } // 1. ๋ณ€๋™์„ฑ ๊ธฐ๋ฐ˜ ์ˆ˜์ต๋ฅ  ๊ฒ€์ฆ (2% ์ด์ƒ ์—ด๋ ค์žˆ๋Š”๊ฐ€?) - println("(dailyData.size * 0.8).toInt() ${(dailyData.size * 0.8).toInt()}") - val volatility = tempAnalyzer.calculateVolatilityForecast(dailyData, (dailyData.size * 0.8).toInt()) + println("(dailyData.size * 0.8).toInt() ${(dailyData.size * 0.3).toInt()}") + val volatility = tempAnalyzer.calculateVolatilityForecast(dailyData, 20) val expectedProfitRate = ((volatility.realisticHigh - currentPrice) / currentPrice) * 100.0 // 2. ์ผ๋ด‰ ๊ธฐ์ค€ ๋ฐ˜๋“ฑ ์ฃผ๊ธฐ ํ†ต๊ณ„ ์ถ”์ถœ (์ผ์ฃผ์ผ ๋‚ด ์Šน๋ถ€ ๊ฐ€๋Šฅํ•œ๊ฐ€?) @@ -1212,7 +1212,7 @@ object AutoTradingManager { if (dropPrediction != null) { // ๐Ÿ’ก [๋ฐฉ์–ด ๋กœ์ง 1] ์•„์ง ๋ฐ”๋‹ฅ๊นŒ์ง€ ํ•œ์ฐธ ๋‚จ์•˜๋‹ค๋ฉด ์ง€ํ•˜์‹ค ๋ฐฉ์ง€ - if (dropPrediction.remainingDropRate < -2.0 && !dropPrediction.isBottomZone) { + if (dropPrediction.remainingDropRate < -1.0 && !dropPrediction.isBottomZone) { print("-> [${stock.name}] ์ง€ํ•˜์‹ค ์ฃผ์˜ (ํ˜„์žฌ ${"%.1f".format(dropPrediction.currentDropRate)}% ํ•˜๋ฝ, ์ถ”๊ฐ€ ํ•˜๋ฝ ์œ„ํ—˜) | ") return@withTimeout }