...
This commit is contained in:
@@ -68,7 +68,7 @@ fun AiAnalysisView(technicalAnalyzer: TechnicalAnalyzer,stockCode:String,stockNa
|
||||
scope.launch {
|
||||
isAnalyzing = true
|
||||
try {
|
||||
AutoTradingManager.addStock(technicalAnalyzer,stockName,stockCode) { decision,success ->
|
||||
AutoTradingManager.addStock(currentPrice.replace(",","").toDouble(),technicalAnalyzer,stockName,stockCode) { decision,success ->
|
||||
aiOpinion = decision.toString()
|
||||
isAnalyzing = !success
|
||||
tradingDecisionCallback.invoke(decision,success)
|
||||
|
||||
@@ -192,12 +192,12 @@ fun IntegratedOrderSection(
|
||||
scope.launch {
|
||||
val tickSize = MarketUtil.getTickSize(basePrice)
|
||||
val oneTickLowerPrice = basePrice - (tickSize * when(investmentGrade) {
|
||||
InvestmentGrade.LEVEL_5_STRONG_RECOMMEND -> 1
|
||||
InvestmentGrade.LEVEL_5_STRONG_RECOMMEND -> 0
|
||||
InvestmentGrade.LEVEL_4_BALANCED_RECOMMEND -> 1
|
||||
InvestmentGrade.LEVEL_3_CAUTIOUS_RECOMMEND -> 2
|
||||
InvestmentGrade.LEVEL_2_HIGH_RISK -> 2
|
||||
InvestmentGrade.LEVEL_1_SPECULATIVE -> 4
|
||||
else -> 4
|
||||
InvestmentGrade.LEVEL_1_SPECULATIVE -> 3
|
||||
else -> 3
|
||||
})
|
||||
|
||||
// 2. 주문 가격 설정 (직접 입력값이 없으면 한 틱 낮은 가격 사용)
|
||||
@@ -255,6 +255,7 @@ fun IntegratedOrderSection(
|
||||
var append = 0.0
|
||||
if (completeTradingDecision != null &&
|
||||
completeTradingDecision.stockCode.equals(stockCode)) {
|
||||
basePrice = completeTradingDecision.currentPrice
|
||||
println("basePrice $basePrice")
|
||||
fun resultCheck(completeTradingDecision :TradingDecision) {
|
||||
val weights = mapOf(
|
||||
@@ -264,14 +265,13 @@ fun IntegratedOrderSection(
|
||||
)
|
||||
|
||||
val totalScore =
|
||||
(completeTradingDecision.shortPossible() * weights["short"]!!) +
|
||||
(completeTradingDecision.profitPossible() * weights["profit"]!!) +
|
||||
(completeTradingDecision.safePossible() * weights["safe"]!!)
|
||||
((completeTradingDecision.shortPossible() + append) * weights["short"]!!) +
|
||||
((completeTradingDecision.profitPossible() + append) * weights["profit"]!!) +
|
||||
((completeTradingDecision.safePossible() + append) * weights["safe"]!!)
|
||||
|
||||
if (totalScore >= MIN_PURCHASE_SCORE && completeTradingDecision.confidence >= MIN_CONFIDENCE) {
|
||||
var investmentGrade : InvestmentGrade = getInvestmentGrade(completeTradingDecision,totalScore, completeTradingDecision.confidence)
|
||||
// 4. 점수에 따른 가변 마진 적용
|
||||
// 토탈 스코어가 85점 이상이면 마진을 3.0으로 고정하거나 추가 가산(append) 적용
|
||||
|
||||
val finalMargin = minimumNetProfit * investmentGrade.profitGuide
|
||||
println("""
|
||||
사명 : ${completeTradingDecision.corpName}
|
||||
@@ -299,7 +299,7 @@ fun IntegratedOrderSection(
|
||||
investmentGrade = investmentGrade,
|
||||
)
|
||||
|
||||
} else if(totalScore >= (MIN_PURCHASE_SCORE * 0.85) && completeTradingDecision.confidence >= (MIN_CONFIDENCE * 0.85)) {
|
||||
} else if(totalScore >= (MIN_PURCHASE_SCORE * 0.85) && completeTradingDecision.confidence + append >= (MIN_CONFIDENCE * 0.85)) {
|
||||
AutoTradingManager.addToReanalysis(RankingStock(mksc_shrn_iscd = completeTradingDecision.stockCode,hts_kor_isnm = completeTradingDecision.stockName))
|
||||
println("✋ [관망] 토탈 스코어 또는 신뢰도 미달 이나 약간의 오차로 재분석 대기열에 추가")
|
||||
} else {
|
||||
|
||||
@@ -60,7 +60,7 @@ fun StockDetailSection(
|
||||
|
||||
// 이전 종목 코드를 기억하기 위한 상태
|
||||
var previousCode by remember { mutableStateOf("") }
|
||||
var latestPrice by remember { mutableStateOf("0") }
|
||||
var lastPrice by remember { mutableStateOf("0") }
|
||||
|
||||
|
||||
// 종목 변경 시 데이터 로드 및 웹소켓 구독 관리
|
||||
@@ -90,7 +90,7 @@ fun StockDetailSection(
|
||||
val price = tradeLog.price
|
||||
wsManager.tradeLogs.add(tradeLog)
|
||||
if (wsManager.tradeLogs.size > 50) wsManager.tradeLogs.removeLast()
|
||||
println("code $code ,price $price")
|
||||
// println("code $code ,price $price")
|
||||
val currentPrice = price
|
||||
if (chartData.isNotEmpty() && currentPrice != "0") {
|
||||
val priceDouble = currentPrice.replace(",", "").toDoubleOrNull() ?: 0.0
|
||||
@@ -123,7 +123,7 @@ fun StockDetailSection(
|
||||
chartData = chartData.dropLast(1) + updatedCandle
|
||||
}
|
||||
}
|
||||
latestPrice = currentPrice
|
||||
lastPrice = currentPrice
|
||||
}
|
||||
|
||||
}
|
||||
@@ -218,7 +218,7 @@ fun StockDetailSection(
|
||||
code = stockCode,
|
||||
isDomestic = isDomestic,
|
||||
previousClose = previousClose,
|
||||
openPrice = latestPrice,
|
||||
openPrice = lastPrice,
|
||||
resultMessage = resultMessage,
|
||||
resultMessageClear = {resultMessage = ""},
|
||||
isSuccess = isSuccess
|
||||
@@ -227,10 +227,10 @@ fun StockDetailSection(
|
||||
// 실시간 가격 표시 (WebSocket 데이터)
|
||||
Column(horizontalAlignment = Alignment.End) {
|
||||
Text(
|
||||
text = "${latestPrice} 원",
|
||||
text = "${lastPrice} 원",
|
||||
style = MaterialTheme.typography.h4,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = if (latestPrice?.contains("-") ?: false) Color.Blue else Color.Red
|
||||
color = if (lastPrice?.contains("-") ?: false) Color.Blue else Color.Red
|
||||
)
|
||||
Text("실시간 체결가", style = MaterialTheme.typography.caption, color = Color.Gray)
|
||||
}
|
||||
@@ -276,7 +276,7 @@ fun StockDetailSection(
|
||||
stockCode = stockCode,
|
||||
stockName = stockName,
|
||||
isDomestic = isDomestic,
|
||||
currentPrice = latestPrice,
|
||||
currentPrice = lastPrice,
|
||||
holdingQuantity = holdingQuantity,
|
||||
tradeService = tradeService,
|
||||
onOrderSaved = onOrderSaved,
|
||||
|
||||
Reference in New Issue
Block a user