Change default candle db1 directory
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user