...
This commit is contained in:
parent
1cca11edc4
commit
ef32260bdb
@ -258,6 +258,9 @@ class TradeConfig {
|
|||||||
var noticeGapTime : Int = 60
|
var noticeGapTime : Int = 60
|
||||||
var lowerAveragePrice : Boolean = false
|
var lowerAveragePrice : Boolean = false
|
||||||
var lowerAverageStockCount : Int = 1
|
var lowerAverageStockCount : Int = 1
|
||||||
|
var lowerAverageMaxRate : Double = 1.0
|
||||||
|
var lowerAverageMinRate : Double = 40.0
|
||||||
|
var lowerAverageTargetCount : Int = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,7 @@ object AutoTradingManager {
|
|||||||
val maxBudget = KisSession.config.getValues(ConfigIndex.MAX_BUDGET_INDEX) * gradeRate
|
val maxBudget = KisSession.config.getValues(ConfigIndex.MAX_BUDGET_INDEX) * gradeRate
|
||||||
|
|
||||||
TradingLogStore.addLog(decision,"BUY",decision.summary())
|
TradingLogStore.addLog(decision,"BUY",decision.summary())
|
||||||
var hasCodes = currentBalance?.getHoldings()?.any { it.code.equals(decision.stockCode) && it.quantity.toInt() > 2 && it.isTodayEntry == false}
|
var hasCodes = currentBalance?.getHoldings()?.any { it.code.equals(decision.stockCode) && it.quantity.toInt() > 2 && !it.isTodayEntry}
|
||||||
if (hasCodes == true) {
|
if (hasCodes == true) {
|
||||||
buysCodes.add(decision.stockCode)
|
buysCodes.add(decision.stockCode)
|
||||||
TradingLogStore.addNotice(decision.stockName,decision.stockCode,"물타기 시도 1주 매수")
|
TradingLogStore.addNotice(decision.stockName,decision.stockCode,"물타기 시도 1주 매수")
|
||||||
@ -380,7 +380,7 @@ object AutoTradingManager {
|
|||||||
|
|
||||||
println("🎊 [매칭 성공] 매도 완료: ${dbItem.name} | 매도가: ${actualSellPrice.toInt()}")
|
println("🎊 [매칭 성공] 매도 완료: ${dbItem.name} | 매도가: ${actualSellPrice.toInt()}")
|
||||||
TradingLogStore.addSellLog(dbItem.name,actualSellPrice.toString(),"SELL","매도 완료")
|
TradingLogStore.addSellLog(dbItem.name,actualSellPrice.toString(),"SELL","매도 완료")
|
||||||
myOredsAndBalanceCodes.remove(dbItem.code)
|
|
||||||
TradingReportManager.closePositionCycle(dbItem.code) // 사이클 종료 알림
|
TradingReportManager.closePositionCycle(dbItem.code) // 사이클 종료 알림
|
||||||
|
|
||||||
DatabaseFactory.updateStatusAndOrderNo(dbItem.id!!, TradeStatus.COMPLETED)
|
DatabaseFactory.updateStatusAndOrderNo(dbItem.id!!, TradeStatus.COMPLETED)
|
||||||
@ -834,7 +834,7 @@ object AutoTradingManager {
|
|||||||
return batch
|
return batch
|
||||||
}
|
}
|
||||||
var currentBalance : UnifiedBalance? = null
|
var currentBalance : UnifiedBalance? = null
|
||||||
var myOredsAndBalanceCodes : MutableSet<String> = mutableSetOf()
|
|
||||||
suspend fun checkBalance(isMorning: Boolean = true) {
|
suspend fun checkBalance(isMorning: Boolean = true) {
|
||||||
if (isMorning) {
|
if (isMorning) {
|
||||||
currentBalance = KisTradeService.fetchIntegratedBalance().getOrNull()
|
currentBalance = KisTradeService.fetchIntegratedBalance().getOrNull()
|
||||||
@ -906,16 +906,10 @@ object AutoTradingManager {
|
|||||||
|
|
||||||
|
|
||||||
suspend fun executeMarketLoop() {
|
suspend fun executeMarketLoop() {
|
||||||
myOredsAndBalanceCodes.clear()
|
|
||||||
checkBalance()
|
checkBalance()
|
||||||
val myCash = currentBalance?.deposit?.replace(",", "")?.toLongOrNull() ?: 0L
|
val myCash = currentBalance?.deposit?.replace(",", "")?.toLongOrNull() ?: 0L
|
||||||
val myHoldings = currentBalance?.getHoldings()?.map {
|
val myHoldings = currentBalance?.getHoldings()?.filter { !it.isTodayEntry }?.map { it.code }?.toSet() ?: emptySet()
|
||||||
myOredsAndBalanceCodes.add(it.code)
|
val pendingStocks = DatabaseFactory.findAllMonitoringTrades().map { it.code }
|
||||||
it.code }?.toSet() ?: emptySet()
|
|
||||||
val pendingStocks = DatabaseFactory.findAllMonitoringTrades().map {
|
|
||||||
myOredsAndBalanceCodes.add(it.code)
|
|
||||||
it.code
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remainingCandidates.isEmpty()) {
|
if (remainingCandidates.isEmpty()) {
|
||||||
if (loadedTops.size < 200) {
|
if (loadedTops.size < 200) {
|
||||||
@ -948,7 +942,7 @@ object AutoTradingManager {
|
|||||||
reanalysisList.clear()
|
reanalysisList.clear()
|
||||||
if (KisSession.tradeConfig.lowerAveragePrice) {
|
if (KisSession.tradeConfig.lowerAveragePrice) {
|
||||||
currentBalance?.getHoldings()?.map {
|
currentBalance?.getHoldings()?.map {
|
||||||
if(!it.isTodayEntry && it.quantity.toInt() > 2) {
|
if(!it.isTodayEntry && it.quantity.toInt() > KisSession.tradeConfig.lowerAverageTargetCount && it.profitRate.toDouble() < (KisSession.tradeConfig.lowerAverageMaxRate * -1) && it.profitRate.toDouble() > (KisSession.tradeConfig.lowerAverageMinRate * -1) ) {
|
||||||
remainingCandidates.add(RankingStock(mksc_shrn_iscd = it.code, hts_kor_isnm = it.name))
|
remainingCandidates.add(RankingStock(mksc_shrn_iscd = it.code, hts_kor_isnm = it.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user