fix(kis): KIS API 초당 호출 한도 초과(Rate Limit) 방지를 위한 딜레이 및 토큰 버킷 상향 안정화
This commit is contained in:
@@ -1604,7 +1604,7 @@ object AutoTradingManager {
|
||||
iterator.remove()
|
||||
}
|
||||
println("남은 후보군 개수 : ${totalCount}")
|
||||
delay(500)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
sellSchedule()
|
||||
@@ -1765,7 +1765,7 @@ object AutoTradingManager {
|
||||
|
||||
if (dailyData.size < 30) return@withTimeout
|
||||
|
||||
delay(40) // API 속도 제한 방어
|
||||
delay(150) // API 속도 제한 방어
|
||||
val weeklyData = tradeService.fetchPeriodChartData(stock.code, "W", true).getOrNull() ?: return@withTimeout
|
||||
if (weeklyData.size < 10) return@withTimeout
|
||||
|
||||
@@ -1780,7 +1780,7 @@ object AutoTradingManager {
|
||||
(rate < KisSession.tradeConfig.plusFilter) && (rate > (abs(KisSession.tradeConfig.minusFilter) * -1))
|
||||
}
|
||||
|
||||
delay(50)
|
||||
delay(150)
|
||||
val currentStock = KisTradeService.fetchCurrentPrice(stock.code).getOrNull() ?: return@withTimeout
|
||||
val currentPrice = currentStock.stck_prpr.toDouble()
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import kotlinx.coroutines.sync.withLock
|
||||
* 스레드 안전 코루틴 토큰 버킷 RateLimiter입니다.
|
||||
*/
|
||||
object KisRateLimiter {
|
||||
// KIS OpenAPI의 안전한 초당 최대 요청 수 (기본 3회/초)
|
||||
private const val MAX_TOKENS = 3
|
||||
// KIS OpenAPI의 안전한 초당 최대 요청 수 (초당 2회로 강화하여 EGW00123/EGW00201 초과 원천 방지)
|
||||
private const val MAX_TOKENS = 2
|
||||
private const val REFILL_INTERVAL_MS = 1000L
|
||||
|
||||
private val mutex = Mutex()
|
||||
|
||||
Reference in New Issue
Block a user