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