File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Sources/Grodt/BusinessLogic/PortfolioPerformance Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ class PortfolioPerformanceUpdater: PortfolioHistoricalPerformanceUpdater {
5353 func recalculateHistoricalPerformance( of portfolio: Portfolio ) async throws {
5454 var datedPerformance = [ DatedPortfolioPerformance] ( )
5555 guard let earliestTransaction = portfolio. earliestTransaction else { return }
56- let dates = dateRangeUntilToday ( from: earliestTransaction. purchaseDate)
56+ let dates = dateRangeUntilYesterday ( from: earliestTransaction. purchaseDate)
5757
5858 for date in dates {
5959 let performanceForDate = try await performanceCalculator. performance ( of: portfolio, on: date)
@@ -72,13 +72,14 @@ class PortfolioPerformanceUpdater: PortfolioHistoricalPerformanceUpdater {
7272 }
7373 }
7474
75- private func dateRangeUntilToday ( from startDate: Date ) -> [ YearMonthDayDate ] {
75+ private func dateRangeUntilYesterday ( from startDate: Date ) -> [ YearMonthDayDate ] {
7676 var dates : [ YearMonthDayDate ] = [ ]
7777 var currentDate = startDate
7878 let calendar = Calendar . current
79- let today = Date ( )
79+ let yesterday = calendar . date ( byAdding : . day , value : - 1 , to : Date ( ) ) !
8080
81- while currentDate <= today {
81+
82+ while currentDate <= yesterday {
8283 let ymdDate = YearMonthDayDate ( currentDate)
8384 dates. append ( ymdDate)
8485 currentDate = calendar. date ( byAdding: . day, value: 1 , to: currentDate) !
You can’t perform that action at this time.
0 commit comments