...
This commit is contained in:
parent
d0bdc57a1e
commit
9d43c04670
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -122,15 +122,18 @@ object KisTradeService {
|
||||
} else 0.0
|
||||
|
||||
// 3. 모델 생성
|
||||
Result.success(UnifiedBalance(
|
||||
totalAsset = String.format("%,d", (domSummary?.tot_evlu_amt?.toLongOrNull() ?: 0L)),
|
||||
deposit = String.format("%,d", domSummary?.dnca_tot_amt?.toLongOrNull() ?: 0L),
|
||||
dailyAssetChange = String.format("%,d", (domSummary?.asst_icdc_amt?.toLongOrNull() ?: 0L)),
|
||||
todayFees = String.format("%,d", (domSummary?.thdt_tlex_amt?.toLongOrNull() ?: 0L)),
|
||||
totalProfitRate = String.format("%.2f%%", calculatedTotalRate), // 계산된 값 전달
|
||||
holdings = combinedHoldings
|
||||
))
|
||||
|
||||
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),
|
||||
dailyAssetChange = String.format("%,d", (domSummary?.asst_icdc_amt?.toLongOrNull() ?: 0L)),
|
||||
todayFees = String.format("%,d", (domSummary?.thdt_tlex_amt?.toLongOrNull() ?: 0L)),
|
||||
totalProfitRate = String.format("%.2f%%", calculatedTotalRate), // 계산된 값 전달
|
||||
holdings = combinedHoldings
|
||||
))
|
||||
} else {
|
||||
Result.failure(Exception("combinedHoldings empty"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Result.failure(e)
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 = "위의 수치 만큼 호가 위로 주문함."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user