Browse Source
Bugfix/set close state in market data gathering for specific date (#8062)
* Fix state of market data in historical market data gathering for specific date
* Update changelog
pull/8289/head
Thomas Kaul
4 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
40 additions and
3 deletions
-
CHANGELOG.md
-
apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts
-
apps/api/src/services/queues/data-gathering/data-gathering.service.ts
|
|
|
@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
- Improved the performance of the historical market data table of the admin control panel by querying subscription usage in a single database query |
|
|
|
- Hardened the `POST api/v1/import` endpoint by hiding internal error messages |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed the state of the market data in the historical market data gathering endpoint for a specific date |
|
|
|
|
|
|
|
## 3.91.0 - 2026-10-23 |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
|
|
@ -263,7 +263,29 @@ describe('DataGatheringService', () => { |
|
|
|
expect(prismaService.marketData.upsert).toHaveBeenCalledWith( |
|
|
|
expect.objectContaining({ |
|
|
|
create: expect.objectContaining({ isCarriedForward: false }), |
|
|
|
update: { marketPrice: 100, isCarriedForward: false } |
|
|
|
update: { isCarriedForward: false, marketPrice: 100, state: 'CLOSE' } |
|
|
|
}) |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('sets the state to INTRADAY for today', async () => { |
|
|
|
jest.useFakeTimers().setSystemTime(new Date('2026-08-22T14:00:00.000Z')); |
|
|
|
|
|
|
|
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: 'INTRADAY' }) |
|
|
|
}) |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -33,7 +33,14 @@ import { InjectQueue } from '@nestjs/bull'; |
|
|
|
import { Inject, Injectable, Logger } from '@nestjs/common'; |
|
|
|
import { Prisma } from '@prisma/client'; |
|
|
|
import { Job, JobOptions, Queue } from 'bull'; |
|
|
|
import { format, min, subDays, subMilliseconds, subYears } from 'date-fns'; |
|
|
|
import { |
|
|
|
format, |
|
|
|
isBefore, |
|
|
|
min, |
|
|
|
subDays, |
|
|
|
subMilliseconds, |
|
|
|
subYears |
|
|
|
} from 'date-fns'; |
|
|
|
import ms, { StringValue } from 'ms'; |
|
|
|
|
|
|
|
@Injectable() |
|
|
|
@ -342,6 +349,10 @@ export class DataGatheringService { |
|
|
|
]?.marketPrice; |
|
|
|
|
|
|
|
if (marketPrice) { |
|
|
|
const state = isBefore(startOfUtcDate, getStartOfUtcDate(new Date())) |
|
|
|
? 'CLOSE' |
|
|
|
: 'INTRADAY'; |
|
|
|
|
|
|
|
return await this.prismaService.marketData.upsert({ |
|
|
|
create: { |
|
|
|
dataSource, |
|
|
|
@ -350,7 +361,7 @@ export class DataGatheringService { |
|
|
|
date: startOfUtcDate, |
|
|
|
isCarriedForward: false |
|
|
|
}, |
|
|
|
update: { marketPrice, isCarriedForward: false }, |
|
|
|
update: { marketPrice, state, isCarriedForward: false }, |
|
|
|
where: { |
|
|
|
dataSource_symbol_date: { |
|
|
|
dataSource, |
|
|
|
|