Change default candle db1 directory

This commit is contained in:
2024-11-14 07:28:40 +09:00
parent d8041915a8
commit d413d36a9d
2 changed files with 9 additions and 11 deletions

View File

@@ -286,7 +286,7 @@ extension KissConsole {
for csvFile in csvFiles {
let candleMinName = CandleMinuteFileName()
if let (_, yyyyMMdd) = candleMinName.matchedUrl(csvFile.path), let year = Int(yyyyMMdd.prefix(4)) {
let yearDbPath = candleMinuteDBPath(productNo: productNo, year: String(year))
let yearDbPath = Self.candleMinuteDBPath(productNo: productNo, year: String(year))
if removeOldDB {
try? FileManager.default.removeItem(at: yearDbPath)
}
@@ -323,16 +323,16 @@ extension KissConsole {
return true
}
private func candleMinuteDBPath(productNo: String, year: String) -> URL {
let dataPath = URL.currentDirectory().appending(path: "data")
let yearDbPath = dataPath.appending(path: "\(productNo)/min/candle-\(year).db1")
static func candleMinuteDBPath(productNo: String, year: String) -> URL {
let dataDbPath = URL.currentDirectory().appending(path: "data-db")
let yearDbPath = dataDbPath.appending(path: "\(productNo)/min/candle-\(year).db1")
return yearDbPath
}
/// - Parameters:
/// trimAfterMarket: 09:00 ~ 16:00 , DB .
func validateCandleMinuteDB(productNo: String, year: String, trimAfterMarket: Bool = true) -> Bool {
let yearDbPath = candleMinuteDBPath(productNo: productNo, year: year)
let yearDbPath = Self.candleMinuteDBPath(productNo: productNo, year: year)
guard let (_, yearCsvFiles) = collectCandleMinuteFiles(productNo: productNo, year: year, month: nil, day: nil).first else {
print("No csv files of productNo: \(productNo), year: \(year)")
return false
@@ -376,7 +376,7 @@ extension KissConsole {
}
func countCandleMinunteDB(productNo: String, year: String) -> Int {
let yearDbPath = candleMinuteDBPath(productNo: productNo, year: year)
let yearDbPath = Self.candleMinuteDBPath(productNo: productNo, year: year)
do {
let db = try KissDB(directory: yearDbPath)
try db.begin()
@@ -399,7 +399,7 @@ extension KissConsole {
}
var candleItems = [Domestic.Candle]()
let yearDbPath = candleMinuteDBPath(productNo: productNo, year: String(year))
let yearDbPath = Self.candleMinuteDBPath(productNo: productNo, year: String(year))
do {
let db = try KissDB(directory: yearDbPath)

View File

@@ -63,11 +63,10 @@ struct DB1_CandleData_Tests: KissTestCase {
let year = Self.year
let month = Self.month
let csvFiles = Self.collectCsv(productNo: productNo, yyyy: year, MM: month)
let dataPath = URL.currentDirectory().appending(path: "data")
var itemCount = 0
for csvFile in csvFiles {
let yearDbPath = dataPath.appending(path: "\(productNo)/min/candle-\(year).db1")
let yearDbPath = KissConsole.candleMinuteDBPath(productNo: productNo, year: year)
try? FileManager.default.createDirectory(at: yearDbPath, withIntermediateDirectories: true)
do {
@@ -97,9 +96,8 @@ struct DB1_CandleData_Tests: KissTestCase {
let productNo = Self.samsungProductNo
let year = Self.year
let yyyyMM = String(year) + Self.month
let dataPath = URL.currentDirectory().appending(path: "data")
let yearDbPath = dataPath.appending(path: "\(productNo)/min/candle-\(year).db1")
let yearDbPath = KissConsole.candleMinuteDBPath(productNo: productNo, year: year)
do {
let db = try KissDB(directory: yearDbPath)
try db.begin()