매입단가 손절
This commit is contained in:
parent
27356f0fc2
commit
92d0a84629
@ -59,9 +59,9 @@ object TradingReportManager : TradingReportService {
|
|||||||
private val activePositions = mutableMapOf<String, String>()
|
private val activePositions = mutableMapOf<String, String>()
|
||||||
|
|
||||||
override fun recordAssetSnapshot(type: SnapshotType, balance: UnifiedBalance, remark: String?) {
|
override fun recordAssetSnapshot(type: SnapshotType, balance: UnifiedBalance, remark: String?) {
|
||||||
if (!KisSession.tradeConfig.useAutoRepost) {
|
// if (!KisSession.tradeConfig.useAutoRepost) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
println("❌ [Report] 리포트 비동기 생성 중 오류 발생: gggg")
|
println("❌ [Report] 리포트 비동기 생성 중 오류 발생: gggg")
|
||||||
val todayDate = LocalDate.now().toString()
|
val todayDate = LocalDate.now().toString()
|
||||||
|
|||||||
@ -442,11 +442,32 @@ object AutoTradingManager {
|
|||||||
&& holding.valuationProfitAmount.toDouble() >= KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)) {
|
&& holding.valuationProfitAmount.toDouble() >= KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)) {
|
||||||
println("${holding.name} ${holding.profitRate.toDouble()} ${holding.valuationProfitAmount.toDouble()} ${KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)} , ${KisSession.config.getValues(ConfigIndex.LOSS_MINRATE)} , ${KisSession.config.getValues(ConfigIndex.STOP_LOSS)}")
|
println("${holding.name} ${holding.profitRate.toDouble()} ${holding.valuationProfitAmount.toDouble()} ${KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)} , ${KisSession.config.getValues(ConfigIndex.LOSS_MINRATE)} , ${KisSession.config.getValues(ConfigIndex.STOP_LOSS)}")
|
||||||
val profit = holding.profitRate.toDouble()
|
val profit = holding.profitRate.toDouble()
|
||||||
TradingLogStore.addNotice(
|
// TradingLogStore.addNotice(
|
||||||
"보유주식[${holding.name}]",
|
// "보유주식[${holding.name}]",
|
||||||
|
// holding.code,
|
||||||
|
// "수익률($profit%) -> ${holding.valuationProfitAmount} 손해 중이며 현제 손절 가이드에 적합함."
|
||||||
|
// )
|
||||||
|
|
||||||
|
var targetPrice = holding.avgPrice.toDouble()
|
||||||
|
|
||||||
|
tradeService.postOrder(
|
||||||
|
stockCode = holding.code,
|
||||||
|
qty = holding.availOrderCount,
|
||||||
|
price = targetPrice.toInt().toString(),
|
||||||
|
isBuy = false,
|
||||||
|
orderDivision = if (marketCode.equals("Y")) "07" else "",
|
||||||
|
marketCode = if (marketCode.equals("Y")) "KRX" else "NXT"
|
||||||
|
).onSuccess { newOrderNo ->
|
||||||
|
println("✅ [${if(marketCode.equals("Y"))"시간외 단일가" else "대체거래소"} 손절가이드에 따라 매매 주문 완료] ${holding.name}: $newOrderNo")
|
||||||
|
TradingLogStore.addSellLog(
|
||||||
holding.code,
|
holding.code,
|
||||||
"수익률($profit%) -> ${holding.valuationProfitAmount} 손해 중이며 현제 손절 가이드에 적합함."
|
targetPrice.toString(),
|
||||||
|
"SELL",
|
||||||
|
"☠️ 보유 주식 손절 처리 [수익률 : ${profit}%] ${holding.valuationProfitAmount} 손해 중이며 ${if(marketCode.equals("Y"))"시간외 단일가" else "대체거래소"}에 손절가이드에 따라 매매 주문 완료."
|
||||||
)
|
)
|
||||||
|
}.onFailure { err->
|
||||||
|
println("✅ [${if(marketCode.equals("Y"))"시간외 단일가" else "대체거래소"} 손절가이드에 따라 매매 주문 실패] ${holding.name}: $err")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
analyzeDeepLossHoldingsAfterMarket(holding)
|
analyzeDeepLossHoldingsAfterMarket(holding)
|
||||||
}
|
}
|
||||||
@ -482,7 +503,9 @@ object AutoTradingManager {
|
|||||||
targetPrice = targetPrice
|
targetPrice = targetPrice
|
||||||
isBefore930 = true
|
isBefore930 = true
|
||||||
} else {
|
} else {
|
||||||
targetPrice = MarketUtil.roundToTickSize(targetPrice + MarketUtil.getTickSize(targetPrice))
|
targetPrice = MarketUtil.roundToTickSize(
|
||||||
|
targetPrice + MarketUtil.getTickSize(targetPrice)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
println("🔄 [보유 주식 주문] ${holding.name} (${holding.code}) 매도 목표 ${targetPrice} 미체결 매도 건 재주문 시도")
|
println("🔄 [보유 주식 주문] ${holding.name} (${holding.code}) 매도 목표 ${targetPrice} 미체결 매도 건 재주문 시도")
|
||||||
tradeService.postOrder(
|
tradeService.postOrder(
|
||||||
@ -498,7 +521,8 @@ object AutoTradingManager {
|
|||||||
"SELL",
|
"SELL",
|
||||||
"🎊 보유 주식[예상수익 : ${holding.profitRate}] ${if (isBefore930) "09:30 이전 현시세{${holding.currentPrice}}로 매도[$targetPrice] 주문" else "09:30 이후 시세{${holding.currentPrice}} 기준 호가 위 매도[$targetPrice] 주문"} 완료"
|
"🎊 보유 주식[예상수익 : ${holding.profitRate}] ${if (isBefore930) "09:30 이전 현시세{${holding.currentPrice}}로 매도[$targetPrice] 주문" else "09:30 이후 시세{${holding.currentPrice}} 기준 호가 위 매도[$targetPrice] 주문"} 완료"
|
||||||
)
|
)
|
||||||
DatabaseFactory.saveAutoTrade(AutoTradeItem(
|
DatabaseFactory.saveAutoTrade(
|
||||||
|
AutoTradeItem(
|
||||||
orderNo = newOrderNo,
|
orderNo = newOrderNo,
|
||||||
code = holding.code,
|
code = holding.code,
|
||||||
name = holding.name,
|
name = holding.name,
|
||||||
@ -509,7 +533,8 @@ object AutoTradingManager {
|
|||||||
stopLossPrice = 0.0,
|
stopLossPrice = 0.0,
|
||||||
status = "SELLING",
|
status = "SELLING",
|
||||||
isDomestic = true
|
isDomestic = true
|
||||||
))
|
)
|
||||||
|
)
|
||||||
syncAndExecute(newOrderNo)
|
syncAndExecute(newOrderNo)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
TradingLogStore.addSellLog(
|
TradingLogStore.addSellLog(
|
||||||
@ -528,8 +553,9 @@ object AutoTradingManager {
|
|||||||
&& holding.valuationProfitAmount.toDouble() >= KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)) {
|
&& holding.valuationProfitAmount.toDouble() >= KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)) {
|
||||||
println("${holding.name} ${holding.profitRate.toDouble()} ${holding.valuationProfitAmount.toDouble()} ${KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)} , ${KisSession.config.getValues(ConfigIndex.LOSS_MINRATE)} , ${KisSession.config.getValues(ConfigIndex.STOP_LOSS)}")
|
println("${holding.name} ${holding.profitRate.toDouble()} ${holding.valuationProfitAmount.toDouble()} ${KisSession.config.getValues(ConfigIndex.LOSS_MAX_MONEY)} , ${KisSession.config.getValues(ConfigIndex.LOSS_MINRATE)} , ${KisSession.config.getValues(ConfigIndex.STOP_LOSS)}")
|
||||||
val profit = holding.profitRate.toDouble()
|
val profit = holding.profitRate.toDouble()
|
||||||
var targetPrice = holding.currentPrice.toDouble()
|
// var targetPrice = holding.currentPrice.toDouble()
|
||||||
targetPrice = MarketUtil.roundToTickSize(targetPrice + (MarketUtil.getTickSize(targetPrice) * 3.0))
|
// targetPrice = MarketUtil.roundToTickSize(targetPrice + (MarketUtil.getTickSize(targetPrice) * 3.0))
|
||||||
|
var targetPrice = holding.avgPrice.toDouble()
|
||||||
|
|
||||||
tradeService.postOrder(
|
tradeService.postOrder(
|
||||||
stockCode = holding.code,
|
stockCode = holding.code,
|
||||||
@ -542,7 +568,7 @@ object AutoTradingManager {
|
|||||||
holding.code,
|
holding.code,
|
||||||
targetPrice.toString(),
|
targetPrice.toString(),
|
||||||
"SELL",
|
"SELL",
|
||||||
"☠️ 보유 주식 손절 처리 [수익률 : ${profit}%] ${holding.valuationProfitAmount} 손해 중이며 현시세{${holding.currentPrice}}로 기준 호가 위 매도[$targetPrice] 주문 완료"
|
"☠️ 보유 주식 손절 처리 [수익률 : ${profit}%] ${holding.valuationProfitAmount} 손해 중이며 현제 손절 가이드에 적합함 시장가 매도."
|
||||||
)
|
)
|
||||||
}.onFailure { err->
|
}.onFailure { err->
|
||||||
println("✅ [보유 주식 손절 처리] 실패 ${err.message}")
|
println("✅ [보유 주식 손절 처리] 실패 ${err.message}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user