From 824733ba453703e5224bbd462d38c5ce6245e0b0 Mon Sep 17 00:00:00 2001 From: ened Date: Fri, 7 Jul 2023 02:35:49 +0900 Subject: [PATCH] Fix bug on "candle day all resume" --- KissMeConsole/Sources/KissConsole.swift | 18 +++++++++++++++--- bin/data | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/KissMeConsole/Sources/KissConsole.swift b/KissMeConsole/Sources/KissConsole.swift index 50e4288..475da4b 100644 --- a/KissMeConsole/Sources/KissConsole.swift +++ b/KissMeConsole/Sources/KissConsole.swift @@ -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 diff --git a/bin/data b/bin/data index 2c0d7bf..ae22bb8 160000 --- a/bin/data +++ b/bin/data @@ -1 +1 @@ -Subproject commit 2c0d7bf82ef77e1c5301dd474f8d640dbf99ce4a +Subproject commit ae22bb858d25d56909087d0fd4ee144b69b3f0de