Clean code
This commit is contained in:
@@ -66,42 +66,6 @@ extension KissConsole {
|
||||
let totalCount = products.reduce(0, { $0 + $1.value.count })
|
||||
print("load products \(totalCount) with \(products.count) key")
|
||||
}
|
||||
|
||||
static func writeShop(_ shopItems: [DomesticShop.Product], fileUrl: URL) {
|
||||
do {
|
||||
try shopItems.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(shopItems.count)")
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
static func writeCandle(_ prices: [Domestic.Candle], fileUrl: URL) {
|
||||
do {
|
||||
try prices.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(prices.count)")
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
static func writeCandle(_ prices: [Domestic.CandlePeriod], fileUrl: URL) {
|
||||
do {
|
||||
try prices.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(prices.count)")
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
static func writeTop(_ tops: [Domestic.Top], fileUrl: URL) {
|
||||
do {
|
||||
try tops.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(tops.count)")
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension KissConsole {
|
||||
|
||||
@@ -103,7 +103,9 @@ extension KissConsole {
|
||||
}
|
||||
|
||||
let fileUrl = candleFileUrl(productNo: productNo, period: period.filePeriod, day: maxTime)
|
||||
KissConsole.writeCandle(candles, fileUrl: fileUrl)
|
||||
try candles.writeCsv(toFile: fileUrl)
|
||||
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(candles.count)")
|
||||
return true
|
||||
} catch {
|
||||
print(error)
|
||||
@@ -167,7 +169,8 @@ extension KissConsole {
|
||||
}
|
||||
|
||||
let fileUrl = candleFileUrl(productNo: productNo, period: .minute, day: maxTime)
|
||||
KissConsole.writeCandle(candles, fileUrl: fileUrl)
|
||||
try candles.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(candles.count)")
|
||||
return true
|
||||
} catch {
|
||||
print("\(error)")
|
||||
|
||||
@@ -346,8 +346,9 @@ extension KissConsole {
|
||||
for item in output {
|
||||
print("\(item.dataRank) \(item.shortProductNo) \(item.htsProductName.maxSpace(20)) \(item.currentStockPrice.maxSpace(10, digitBy: 3)) \(item.averageVolume.maxSpace(15, digitBy: 3)) \(item.accumulatedTradingAmount.maxSpace(25, digitBy: 3))")
|
||||
}
|
||||
KissConsole.writeTop(output, fileUrl: topProductsUrl(belongClass))
|
||||
|
||||
let fileUrl = topProductsUrl(belongClass)
|
||||
try output.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(output.count)")
|
||||
} catch {
|
||||
print("\(error)")
|
||||
}
|
||||
@@ -694,7 +695,13 @@ extension KissConsole {
|
||||
}
|
||||
}
|
||||
|
||||
KissConsole.writeShop(shopItems, fileUrl: shopProductsUrl)
|
||||
do {
|
||||
let fileUrl = shopProductsUrl
|
||||
try shopItems.writeCsv(toFile: fileUrl)
|
||||
print("wrote \(fileUrl.lastPathComponent) with \(shopItems.count)")
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
private func getAllProduct(baseDate: Date) async -> [DomesticShop.Product] {
|
||||
|
||||
Reference in New Issue
Block a user