Fix bug on "candle day all resume"

This commit is contained in:
2023-07-07 02:35:49 +09:00
parent 3a43542040
commit 824733ba45
2 changed files with 16 additions and 4 deletions

View File

@@ -27,7 +27,9 @@ class KissConsole: KissMe.ShopContext {
var indexContext: IndexContext
let maxCandleDay: Int = 250
private enum KissCommand: String {
case quit = "quit"
@@ -678,7 +680,7 @@ extension KissConsole {
let semaphore = DispatchSemaphore(value: 0)
Task {
let success = await getCandle(productNo: productNo, period: .daily, count: 250, startDate: nil)
let success = await getCandle(productNo: productNo, period: .daily, count: maxCandleDay, startDate: nil)
print("DONE \(success) \(productNo)")
semaphore.signal()
}
@@ -700,7 +702,17 @@ extension KissConsole {
return
}
let success = await getCandle(productNo: item.shortCode, period: .daily, count: 250, startDate: startDate)
let count: Int
if let startDate = startDate {
let daysBefore = ceil(startDate.distance(to: Date()) / SecondsForOneDay)
count = Int(daysBefore)
}
else {
count = maxCandleDay
}
let success = await getCandle(productNo: item.shortCode, period: .daily, count: count, startDate: startDate)
print("DONE \(success) \(item.shortCode)")
semaphore.signal()
#if DEBUG