This commit is contained in:
lunaticbum 2026-06-02 11:19:31 +09:00
parent d0bdc57a1e
commit 9d43c04670
4 changed files with 56 additions and 12 deletions

View File

@ -261,6 +261,9 @@ class TradeConfig {
var lowerAverageMaxRate : Double = 15.0
var lowerAverageMinRate : Double = 25.0
var lowerAverageTargetCount : Int = 2
var autoSellOrderMin : Double = -15.0
var autoSellOrderMax : Double = -29.0
var autoSellOrderAppend : Int = 3
}

View File

@ -122,6 +122,7 @@ object KisTradeService {
} else 0.0
// 3. 모델 생성
if (combinedHoldings.isNotEmpty()) {
Result.success(UnifiedBalance(
totalAsset = String.format("%,d", (domSummary?.tot_evlu_amt?.toLongOrNull() ?: 0L)),
deposit = String.format("%,d", domSummary?.dnca_tot_amt?.toLongOrNull() ?: 0L),
@ -130,7 +131,9 @@ object KisTradeService {
totalProfitRate = String.format("%.2f%%", calculatedTotalRate), // 계산된 값 전달
holdings = combinedHoldings
))
} else {
Result.failure(Exception("combinedHoldings empty"))
}
} catch (e: Exception) {
Result.failure(e)
}

View File

@ -568,11 +568,11 @@ object AutoTradingManager {
if (KisSession.tradeConfig.autoSellOrder
&& holding != null && holding.quantity.toInt() > 0
&& holding.availOrderCount.toInt() > 0
&& holding.profitRate.toDouble() <= -15.0
&& holding.profitRate.toDouble() >= -29.0
&& holding.profitRate.toDouble() <= KisSession.tradeConfig.autoSellOrderMin
&& holding.profitRate.toDouble() >= KisSession.tradeConfig.autoSellOrderMax
&& holding.avgPrice.toDouble() > holding.currentPrice.toDouble()) {
var targetPrice = holding.avgPrice.toDouble()
targetPrice = MarketUtil.roundToTickSize(targetPrice + MarketUtil.getTickSize(targetPrice) * 3.0)
targetPrice = MarketUtil.roundToTickSize(targetPrice + MarketUtil.getTickSize(targetPrice) * KisSession.tradeConfig.autoSellOrderAppend)
tradeService.postOrder(
stockCode = holding.code,
qty = holding.availOrderCount,

View File

@ -643,6 +643,44 @@ fun TradingDecisionLog() {
helperText = "1만큼 사고 팜"
)
}
SettingSwitchField(
label = "아침 자동 매도 주문",
initialChecked = tradeConfig.autoSellOrder,
onCheckedChange = { tradeConfig.autoSellOrder = it
KisSession.saveTradeConfig() }
)
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
SettingInputField(
modifier = Modifier.weight(1.0f, true),
label = "자동 매도 기준 최저가",
initialValue = (tradeConfig.autoSellOrderMin).toString(),
onSave = {
tradeConfig.autoSellOrderMin = it.toDouble()
KisSession.saveTradeConfig()
},
helperText = "이것보다 작아야 주문"
)
SettingInputField(
modifier = Modifier.weight(1.0f, true),
label = "자동 매도 기준 최고가",
initialValue = (tradeConfig.autoSellOrderMax).toString(),
onSave = {
tradeConfig.autoSellOrderMax = it.toDouble()
KisSession.saveTradeConfig()
},
helperText = "이것보다 커야 주문"
)
SettingInputField(
modifier = Modifier.weight(1.0f, true),
label = "매입가 기준 호가위로 주문",
initialValue = (tradeConfig.autoSellOrderAppend).toString(),
onSave = {
tradeConfig.autoSellOrderAppend = it.toInt()
KisSession.saveTradeConfig()
},
helperText = "위의 수치 만큼 호가 위로 주문함."
)
}
}
}
}