Browse Source

Bugfix/countries in FMP service (#6005)

* Introduce countries mapping

* Update changelog
pull/6010/head
Thomas Kaul 21 hours ago
committed by GitHub
parent
commit
a2498a54a6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      CHANGELOG.md
  2. 22
      apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

4
CHANGELOG.md

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Extended the _Storybook_ stories of the portfolio proportion chart component by a story using percentage values - Extended the _Storybook_ stories of the portfolio proportion chart component by a story using percentage values
### Fixed
- Improved the country weightings in the _Financial Modeling Prep_ service
## 2.220.0 - 2025-11-29 ## 2.220.0 - 2025-11-29
### Changed ### Changed

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

@ -44,6 +44,12 @@ import {
@Injectable() @Injectable()
export class FinancialModelingPrepService implements DataProviderInterface { export class FinancialModelingPrepService implements DataProviderInterface {
private static countriesMapping = {
'Korea (the Republic of)': 'South Korea',
'Russian Federation': 'Russia',
'Taiwan (Province of China)': 'Taiwan'
};
private apiKey: string; private apiKey: string;
public constructor( public constructor(
@ -121,12 +127,19 @@ export class FinancialModelingPrepService implements DataProviderInterface {
} }
).then((res) => res.json()); ).then((res) => res.json());
response.countries = etfCountryWeightings.map( response.countries = etfCountryWeightings
({ country: countryName, weightPercentage }) => { .filter(({ country: countryName }) => {
return countryName.toLowerCase() !== 'other';
})
.map(({ country: countryName, weightPercentage }) => {
let countryCode: string; let countryCode: string;
for (const [code, country] of Object.entries(countries)) { for (const [code, country] of Object.entries(countries)) {
if (country.name === countryName) { if (
country.name === countryName ||
country.name ===
FinancialModelingPrepService.countriesMapping[countryName]
) {
countryCode = code; countryCode = code;
break; break;
} }
@ -136,8 +149,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
code: countryCode, code: countryCode,
weight: parseFloat(weightPercentage.slice(0, -1)) / 100 weight: parseFloat(weightPercentage.slice(0, -1)) / 100
}; };
} });
);
const etfHoldings = await fetch( const etfHoldings = await fetch(
`${this.getUrl({ version: 'stable' })}/etf/holdings?symbol=${symbol}&apikey=${this.apiKey}`, `${this.getUrl({ version: 'stable' })}/etf/holdings?symbol=${symbol}&apikey=${this.apiKey}`,

Loading…
Cancel
Save