diff --git a/CHANGELOG.md b/CHANGELOG.md index 8182f9d527..c592a89f84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed the missing thousands separator of 4-digit numbers in certain locales - Fixed an issue where holdings without a market price have been valued at the unit price of a dividend, a fee, an interest or a liability - Fixed the check for today in the current rate service for instances running in a time zone behind UTC +- Fixed the state of the market data in the historical market data gathering endpoint for a specific date ## 3.79.0 - 2026-10-04 diff --git a/apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts b/apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts index 4fc80d3d64..cdd4024a11 100644 --- a/apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts +++ b/apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts @@ -222,7 +222,27 @@ describe('DataGatheringService', () => { expect(prismaService.marketData.upsert).toHaveBeenCalledWith( expect.objectContaining({ create: expect.objectContaining({ isCarriedForward: false }), - update: { marketPrice: 100, isCarriedForward: false } + update: { marketPrice: 100, isCarriedForward: false, state: 'CLOSE' } + }) + ); + }); + + it('sets the state to CLOSE on a previously intraday market price', async () => { + dataProviderService.getHistoricalRaw.mockResolvedValue({ + 'YAHOO-AAPL': { + '2026-08-22': { marketPrice: 100 } + } + }); + + await dataGatheringService.gatherSymbolForDate({ + dataSource: 'YAHOO', + date: parseDate('2026-08-22'), + symbol: 'AAPL' + }); + + expect(prismaService.marketData.upsert).toHaveBeenCalledWith( + expect.objectContaining({ + update: expect.objectContaining({ state: 'CLOSE' }) }) ); }); diff --git a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts index 2897855b01..48ebf09001 100644 --- a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts +++ b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts @@ -346,7 +346,7 @@ export class DataGatheringService { date: startOfUtcDate, isCarriedForward: false }, - update: { marketPrice, isCarriedForward: false }, + update: { marketPrice, isCarriedForward: false, state: 'CLOSE' }, where: { dataSource_symbol_date: { dataSource,