Browse Source

Fix state of market data in historical market data gathering for specific date

pull/8062/head
Thomas Kaul 1 week ago
parent
commit
e017d4638a
  1. 22
      apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts
  2. 2
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts

22
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' })
})
);
});

2
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_date_symbol: {
dataSource,

Loading…
Cancel
Save