Browse Source

Bugfix/handle unknown country names in data enhancer for asset profile data (#7574)

* Handle unknown country names

* Update changelog
pull/7551/head^2
Thomas Kaul 1 week ago
committed by GitHub
parent
commit
7754864419
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      CHANGELOG.md
  2. 7
      apps/api/src/helper/country.helper.ts
  3. 10
      apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts
  4. 6
      apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

5
CHANGELOG.md

@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
### Fixed
- Resolved an issue with unknown country names in the country weightings of the _Financial Modeling Prep_ service
- Resolved an issue with unknown country names in the data enhancer for asset profile data via _Trackinsight_
## 3.45.0 - 2026-08-08 ## 3.45.0 - 2026-08-08
### Added ### Added

7
apps/api/src/helper/country.helper.ts

@ -1,3 +1,4 @@
import { Logger } from '@nestjs/common';
import { countries } from 'countries-list'; import { countries } from 'countries-list';
export function getCountryCodeByName({ export function getCountryCodeByName({
@ -17,5 +18,11 @@ export function getCountryCodeByName({
} }
} }
if (name) {
const logger = new Logger('getCountryCodeByName');
logger.warn(`Could not map the country "${name}" to a code`);
}
return undefined; return undefined;
} }

10
apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts

@ -16,6 +16,7 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface {
private static baseUrl = 'https://www.trackinsight.com'; private static baseUrl = 'https://www.trackinsight.com';
private static countriesMapping = { private static countriesMapping = {
'Czech Republic': 'CZ',
'Republic of Korea': 'KR', 'Republic of Korea': 'KR',
'Russian Federation': 'RU', 'Russian Federation': 'RU',
Turkey: 'TR', Turkey: 'TR',
@ -125,13 +126,14 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface {
for (const [name, value] of Object.entries<any>( for (const [name, value] of Object.entries<any>(
holdings?.countries ?? {} holdings?.countries ?? {}
)) { )) {
response.countries.push({ const code = getCountryCodeByName({
code: getCountryCodeByName({
name, name,
aliases: TrackinsightDataEnhancerService.countriesMapping aliases: TrackinsightDataEnhancerService.countriesMapping
}),
weight: value.weight
}); });
if (code) {
response.countries.push({ code, weight: value.weight });
}
} }
} }

6
apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

@ -169,9 +169,6 @@ export class FinancialModelingPrepService
.then((res) => res.json()); .then((res) => res.json());
response.countries = etfCountryWeightings response.countries = etfCountryWeightings
.filter(({ country: countryName }) => {
return countryName.toLowerCase() !== 'other';
})
.map(({ country: countryName, weightPercentage }) => { .map(({ country: countryName, weightPercentage }) => {
return { return {
code: getCountryCodeByName({ code: getCountryCodeByName({
@ -180,6 +177,9 @@ export class FinancialModelingPrepService
}), }),
weight: parseFloat(`${weightPercentage}`) / 100 weight: parseFloat(`${weightPercentage}`) / 100
}; };
})
.filter(({ code }) => {
return !!code;
}); });
const etfHoldings = await this.fetchService const etfHoldings = await this.fetchService

Loading…
Cancel
Save