.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package util
|
||||
|
||||
import java.io.File
|
||||
import java.util.Properties
|
||||
object AppConfigManager {
|
||||
private val props = Properties()
|
||||
private val configFile = File("app.properties")
|
||||
|
||||
// API 및 계좌 설정
|
||||
var appKey: String by PropertyDelegate("app_key", "")
|
||||
var secretKey: String by PropertyDelegate("secret_key", "")
|
||||
var accountNo: String by PropertyDelegate("account_no", "")
|
||||
var isSimulation: Boolean by PropertyDelegate("is_simulation", "true") { it.toBoolean() }
|
||||
|
||||
// AI 모델 설정
|
||||
var modelPath: String by PropertyDelegate("model_path", "")
|
||||
|
||||
init {
|
||||
if (configFile.exists()) configFile.inputStream().use { props.load(it) }
|
||||
}
|
||||
|
||||
private fun save() = configFile.outputStream().use { props.store(it, "AutoTrade Config") }
|
||||
|
||||
// 델리게이트 패턴으로 중복 코드 방지
|
||||
class PropertyDelegate<T>(
|
||||
private val key: String,
|
||||
private val default: String,
|
||||
private val parser: (String) -> T = { it as T }
|
||||
) {
|
||||
operator fun getValue(thisRef: Any?, property: kotlin.reflect.KProperty<*>): T =
|
||||
parser(props.getProperty(key, default))
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: kotlin.reflect.KProperty<*>, value: T) {
|
||||
props.setProperty(key, value.toString())
|
||||
save()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package util
|
||||
|
||||
import java.time.LocalTime
|
||||
import java.time.ZoneId
|
||||
|
||||
object MarketUtil {
|
||||
fun isKoreanMarketOpen(): Boolean {
|
||||
// 한국 시간대 기준 현재 시간 가져오기
|
||||
val now = LocalTime.now(ZoneId.of("Asia/Seoul"))
|
||||
val start = LocalTime.of(9, 0)
|
||||
val end = LocalTime.of(15, 30)
|
||||
|
||||
// 주말 제외 로직은 필요시 추가 (일단 시간대 우선)
|
||||
return now.isAfter(start) && now.isBefore(end)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user