Browse Source

Bugfix/response of historical market data gathering for a specific date (#7717)

* Fix response of historical market data gathering for a specific date

* Update changelog
pull/7722/head
Thomas Kaul 3 days ago
committed by GitHub
parent
commit
0d0ed97227
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 11
      apps/api/src/app/admin/admin.controller.ts
  3. 29
      apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts
  4. 6
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts

1
CHANGELOG.md

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Migrated the create and edit access dialogs to dedicated routes - Migrated the create and edit access dialogs to dedicated routes
- Improved the response of the historical market data gathering endpoint for a specific date
### Fixed ### Fixed

11
apps/api/src/app/admin/admin.controller.ts

@ -213,11 +213,20 @@ export class AdminController {
); );
} }
return this.dataGatheringService.gatherSymbolForDate({ const marketData = await this.dataGatheringService.gatherSymbolForDate({
dataSource, dataSource,
date, date,
symbol symbol
}); });
if (!marketData) {
throw new HttpException(
getReasonPhrase(StatusCodes.NOT_FOUND),
StatusCodes.NOT_FOUND
);
}
return marketData;
} }
@HasPermission(permissions.accessAdminControl) @HasPermission(permissions.accessAdminControl)

29
apps/api/src/services/queues/data-gathering/data-gathering.service.spec.ts

@ -219,5 +219,34 @@ describe('DataGatheringService', () => {
}) })
); );
}); });
it('returns the upserted market data', async () => {
dataProviderService.getHistoricalRaw.mockResolvedValue({
'YAHOO-AAPL': {
'2026-08-22': { marketPrice: 100 }
}
});
prismaService.marketData.upsert.mockResolvedValue({ marketPrice: 100 });
const marketData = await dataGatheringService.gatherSymbolForDate({
dataSource: 'YAHOO',
date: parseDate('2026-08-22'),
symbol: 'AAPL'
});
expect(marketData).toEqual({ marketPrice: 100 });
});
it('returns undefined if the data provider has no market price', async () => {
dataProviderService.getHistoricalRaw.mockResolvedValue({});
const marketData = await dataGatheringService.gatherSymbolForDate({
dataSource: 'YAHOO',
date: parseDate('2026-08-22'),
symbol: 'AAPL'
});
expect(marketData).toBeUndefined();
});
}); });
}); });

6
apps/api/src/services/queues/data-gathering/data-gathering.service.ts

@ -348,10 +348,10 @@ export class DataGatheringService {
}); });
} }
} catch (error) { } catch (error) {
this.logger.error(error.message); this.logger.error(error?.message);
} finally {
return undefined;
} }
return undefined;
} }
public async gatherSymbols({ public async gatherSymbols({

Loading…
Cancel
Save