Browse Source

Bugfix/add missing country mapping for Czech Republic and Turkey (#7611)

* Add missing country mapping for Czech Republic and Turkey

* Update changelog
pull/7610/head
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
b764faff9e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      CHANGELOG.md
  2. 2
      apps/api/src/helper/country.helper.ts
  3. 14
      apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts
  4. 3
      apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

5
CHANGELOG.md

@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Resolved an error when fetching dividends from _Yahoo Finance_ for date ranges without events
### Fixed
- Fixed the missing mapping for Turkey in the country weightings of the _Financial Modeling Prep_ service
- Fixed the missing mapping for Czech Republic and Turkey in the data enhancer for asset profile data via _Yahoo Finance_
## 3.49.0 - 2026-08-12
### Changed

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

@ -18,7 +18,7 @@ export function getCountryCodeByName({
}
}
if (name) {
if (name && name.toLowerCase() !== 'other') {
const logger = new Logger('getCountryCodeByName');
logger.warn(`Could not map the country "${name}" to a code`);

14
apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

@ -1,3 +1,4 @@
import { getCountryCodeByName } from '@ghostfolio/api/helper/country.helper';
import { getSectorName } from '@ghostfolio/api/helper/sector.helper';
import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service';
import { AssetProfileDelistedError } from '@ghostfolio/api/services/data-provider/errors/asset-profile-delisted.error';
@ -18,12 +19,16 @@ import {
SymbolProfile
} from '@prisma/client';
import { isISIN } from 'class-validator';
import { countries } from 'countries-list';
import YahooFinance from 'yahoo-finance2';
import type { Price } from 'yahoo-finance2/esm/src/modules/quoteSummary-iface';
@Injectable()
export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
private static countriesMapping = {
'Czech Republic': 'CZ',
Turkey: 'TR'
};
private static sectorsMapping: Record<string, SectorName> = {
basic_materials: 'Basic Materials',
communication_services: 'Communication Services',
@ -246,15 +251,14 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
) {
// Add country if asset is stock and country available
try {
const [code] = Object.entries(countries).find(([, country]) => {
return country.name === assetProfile.summaryProfile?.country;
const code = getCountryCodeByName({
aliases: YahooFinanceDataEnhancerService.countriesMapping,
name: assetProfile.summaryProfile.country
});
if (code) {
response.countries = [{ code, weight: 1 }];
}
} catch {}
if (assetProfile.summaryProfile?.sector) {
response.sectors = [

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

@ -56,7 +56,8 @@ export class FinancialModelingPrepService
private static countriesMapping = {
'Korea (the Republic of)': 'KR',
'Russian Federation': 'RU',
'Taiwan (Province of China)': 'TW'
'Taiwan (Province of China)': 'TW',
Turkey: 'TR'
};
private readonly logger = new Logger(FinancialModelingPrepService.name);

Loading…
Cancel
Save