...
This commit is contained in:
@@ -3,6 +3,8 @@ package network
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import model.KisSession
|
||||
import model.RankingStock
|
||||
import service.AutoTradingManager
|
||||
@@ -11,6 +13,36 @@ import java.io.File
|
||||
import java.util.zip.ZipInputStream
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
|
||||
@Serializable
|
||||
data class StockItem(
|
||||
val code: String,
|
||||
val name: String
|
||||
){}
|
||||
|
||||
object StockUniverseLoader {
|
||||
private val json = Json { ignoreUnknownKeys = true }
|
||||
|
||||
fun loadUniverse(filePath: String = "stocks_universe.json"): List<Pair<String, String>> {
|
||||
return try {
|
||||
val file = File(filePath)
|
||||
if (!file.exists()) {
|
||||
println("⚠️ 파일을 찾을 수 없습니다: ${file.absolutePath}")
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
// 1. JSON 파일 읽기 및 역직렬화
|
||||
val rawJson = file.readText()
|
||||
val stockItems = json.decodeFromString<List<StockItem>>(rawJson)
|
||||
|
||||
// 2. Pair(코드, 이름) 튜플 리스트로 변환
|
||||
stockItems.map { it.code to it.name }
|
||||
} catch (e: Exception) {
|
||||
println("❌ 유니버스 로드 실패: ${e.message}")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data class CorpInfo(
|
||||
var cCode : String = "",
|
||||
@@ -83,6 +115,7 @@ object DartCodeManager {
|
||||
}
|
||||
}
|
||||
|
||||
fun getStockCodez() : Array<String> = corpCodeMap.keys.toTypedArray()
|
||||
/**
|
||||
* 6자리 종목코드로 8자리 법인코드 반환
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user