...
This commit is contained in:
parent
d57f1698af
commit
aa4f8daadf
@ -238,13 +238,16 @@ object AutoTradingManager {
|
||||
var tax = KisSession.config.getValues(ConfigIndex.TAX_INDEX)
|
||||
val effectiveProfitRate =
|
||||
(profitRate1 ?: KisSession.config.getValues(ConfigIndex.PROFIT_INDEX)) + tax
|
||||
var oldTarget = currentBalance?.getHoldings()?.filter { it.code.equals(decision.stockCode) }?.first()
|
||||
try {
|
||||
var oldTarget = currentBalance?.getHoldings()?.first { it.availOrderCount.toInt() > 0 && it.code.equals(decision.stockCode) }
|
||||
if (hasCode && oldTarget != null) {
|
||||
var avgPrive = oldTarget.avgPrice.toDouble()
|
||||
var qty = oldTarget.quantity.toDouble()
|
||||
basePrice = ((avgPrive * qty) + (decision.currentPrice * orderQty.toInt())).div(qty!!.toInt() + (orderQty.toInt()))
|
||||
println("물타기 ${avgPrive}, ${qty} ${basePrice}")
|
||||
}
|
||||
} catch (e:Exception) {e.printStackTrace()}
|
||||
|
||||
|
||||
val calculatedTarget =
|
||||
MarketUtil.roundToTickSize(basePrice * (1 + effectiveProfitRate / 100.0))
|
||||
@ -326,6 +329,7 @@ object AutoTradingManager {
|
||||
var onExecutionReceived : ((String, String, String, String, Boolean) -> Unit)? = {code, qty, price,orderNo, isBuy ->
|
||||
scope.launch {
|
||||
val exec = ExecutionData(orderNo, code, price, qty, isBuy)
|
||||
println("exec >> ${exec}")
|
||||
executionCache[orderNo] = exec
|
||||
syncAndExecute(orderNo)
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ object MarketUtil {
|
||||
holiDays.put(todayStr, isHoliday)
|
||||
|
||||
println("🌐 [API Call] 오늘($todayStr)의 휴장 여부를 새로 조회하여 DB에 저장했습니다.")
|
||||
!isHoliday
|
||||
isHoliday
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user