From b764faff9e418879a33eb41bba87b433856c9509 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 13 Aug 2026 20:13:01 +0200 Subject: [PATCH] Bugfix/add missing country mapping for Czech Republic and Turkey (#7611) * Add missing country mapping for Czech Republic and Turkey * Update changelog --- CHANGELOG.md | 5 +++++ apps/api/src/helper/country.helper.ts | 2 +- .../yahoo-finance/yahoo-finance.service.ts | 22 +++++++++++-------- .../financial-modeling-prep.service.ts | 3 ++- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c805c2586..53235aaf4 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/apps/api/src/helper/country.helper.ts b/apps/api/src/helper/country.helper.ts index ecb28b8d3..2e6da5340 100644 --- a/apps/api/src/helper/country.helper.ts +++ b/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`); diff --git a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts index 749f10c12..f2cbcf8ea 100644 --- a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts +++ b/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 = { 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 (code) { + response.countries = [{ code, weight: 1 }]; + } if (assetProfile.summaryProfile?.sector) { response.sectors = [ diff --git a/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts b/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts index f4c36d256..913214b41 100644 --- a/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts +++ b/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);