....
This commit is contained in:
@@ -7,6 +7,7 @@ import Defines.LLM_PORT
|
||||
import TradingLogStore
|
||||
import TradingLogStore.noticeFilter
|
||||
import analyzer.AdvancedTradeAssistant
|
||||
import analyzer.RiskManager
|
||||
import analyzer.TechnicalAnalyzer
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -1147,19 +1148,35 @@ object AutoTradingManager {
|
||||
val today = dailyData.lastOrNull() ?: null
|
||||
var rate = today?.getFluctuationRate() ?: 0.0
|
||||
val isOk = ((rate < KisSession.tradeConfig.plusFilter) && (rate > (abs(KisSession.tradeConfig.minusFilter) * -1)))
|
||||
println("${stock.name}[${stock.code}] 변동률 : ${rate} , 거래 기준 : ${isOk}")
|
||||
if (today == null) {
|
||||
failList.add(stock.code)
|
||||
delay(50)
|
||||
// 1. var 대신 val을 사용해야 아래에서 스마트 캐스트가 작동하여 !!를 안 써도 됩니다.
|
||||
val currentStock = KisTradeService.fetchCurrentPrice(stock.code).getOrNull()
|
||||
|
||||
if (today == null || currentStock == null) {
|
||||
// failList.add(stock.code)
|
||||
print("-> 금일 금액 조회 실패 | ${isOk}")
|
||||
return@withTimeout
|
||||
}
|
||||
val currentPrice = today.stck_prpr.toDouble()
|
||||
// 3. 위에서 확실하게 null 체크를 했으므로, 이제 currentStock은 절대 null이 아닙니다.
|
||||
// 안전하게(Safe call ? 없이) 바로 접근 가능합니다.
|
||||
val currentPrice = currentStock.stck_prpr.toDouble()
|
||||
println("${stock.name}[${stock.code}] 현재가 : ${currentPrice} , 변동률 : ${rate} , 거래 기준 : ${isOk}")
|
||||
|
||||
// 4. 위험한 !! 단언 기호 없이 깔끔하게 호출
|
||||
val riskResult = RiskManager.evaluateRisk(currentStock)
|
||||
if (!riskResult.isSafe) {
|
||||
print("-> ${stock.name}[${stock.code}] 검문소 탈락: ${riskResult.rejectReason}")
|
||||
return@withTimeout
|
||||
}
|
||||
|
||||
|
||||
if (!isOk || (myCash > 10L && currentPrice > myCash) || currentPrice > maxBudget || currentPrice > maxPrice || currentPrice < minPrice) {
|
||||
print("-> [${stock.name}] 가격 정책으로 제외 [1주:${currentPrice}, 자산:${myCash}, 최소 기준:${minPrice}, 최대 기준:${maxPrice}] | ")
|
||||
return@withTimeout
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 🌟 [추가] 고도화된 사전 필터링 (검문소)
|
||||
val tempAnalyzer = TechnicalAnalyzer().apply { this.daily = dailyData }
|
||||
|
||||
@@ -1258,6 +1275,7 @@ object AutoTradingManager {
|
||||
println("✅ [분석 종료] ${stock.name} (${LocalTime.now()})")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
println("❌ [Stock Error] ${stock.name}: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user