...
This commit is contained in:
@@ -90,6 +90,12 @@ object TradeLogTable : Table("trade_logs") {
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
|
||||
object HolidayTable : Table("holiday_cache") {
|
||||
val bassDt = varchar("bass_dt", 8) // YYYYMMDD
|
||||
val isHoliday = bool("is_holiday")
|
||||
override val primaryKey = PrimaryKey(bassDt)
|
||||
}
|
||||
|
||||
object DatabaseFactory {
|
||||
fun init() {
|
||||
val dbPath = File("db/autotrade_db").absolutePath
|
||||
@@ -101,10 +107,23 @@ object DatabaseFactory {
|
||||
transaction {
|
||||
|
||||
// 테이블 생성 (AutoTradeTable 포함)
|
||||
SchemaUtils.createMissingTablesAndColumns(ConfigTable, TradeLogTable, AutoTradeTable)
|
||||
SchemaUtils.createMissingTablesAndColumns(ConfigTable, TradeLogTable, AutoTradeTable,HolidayTable)
|
||||
}
|
||||
}
|
||||
|
||||
fun saveHoliday(date: String, holiday: Boolean) = transaction {
|
||||
HolidayTable.replace {
|
||||
it[bassDt] = date
|
||||
it[isHoliday] = holiday
|
||||
}
|
||||
}
|
||||
|
||||
// 특정 날짜의 휴장 여부 조회
|
||||
fun getHoliday(date: String): Boolean? = transaction {
|
||||
HolidayTable.select { HolidayTable.bassDt eq date }
|
||||
.map { it[HolidayTable.isHoliday] }
|
||||
.singleOrNull()
|
||||
}
|
||||
|
||||
/**
|
||||
* 새로운 자동매매 건 등록 (주로 PENDING_BUY 상태로 시작)
|
||||
|
||||
Reference in New Issue
Block a user