Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/beautify etf names in asset profile (#842)
Thomas Kaul90efc2ac51ec
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 67bb0e8865..0fcba5e498 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Added the total amount to the tooltip in the chart of the _FIRE_ calculator+### Changed++- Beautified the ETF names in the symbol profile+### Fixed- Fixed an issue with changing the investment horizon in the chart of the _FIRE_ calculatordiff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.tsindex b5a0932fbc..b5d8e1ebd3 100644--- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts+++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts@@ -20,7 +20,10 @@ import Big from 'big.js';import { countries } from 'countries-list';import { addDays, format, isSameDay } from 'date-fns';import yahooFinance from 'yahoo-finance2';-import type { Price } from 'yahoo-finance2/dist/esm/src/modules/quoteSummary-iface';+import type {+ Price,+ QuoteSummaryResult+} from 'yahoo-finance2/dist/esm/src/modules/quoteSummary-iface';@Injectable()export class YahooFinanceService implements DataProviderInterface {@@ -89,8 +92,7 @@ export class YahooFinanceService implements DataProviderInterface {response.assetSubClass = assetSubClass;response.currency = assetProfile.price.currency;response.dataSource = this.getName();- response.name =- assetProfile.price.longName || assetProfile.price.shortName || symbol;+ response.name = this.formatName(assetProfile);response.symbol = aSymbol;if (@@ -296,6 +298,25 @@ export class YahooFinanceService implements DataProviderInterface {return { items };}+ private formatName(aAssetProfile: QuoteSummaryResult) {+ let name = aAssetProfile.price.longName;++ if (name) {+ name = name.replace('iShares ETF (CH) - ', '');+ name = name.replace('iShares III Public Limited Company - ', '');+ name = name.replace('iShares VI Public Limited Company - ', '');+ name = name.replace('iShares VII PLC - ', '');+ name = name.replace('Multi Units Luxembourg - ', '');+ name = name.replace('VanEck ETFs N.V. - ', '');+ name = name.replace('Vaneck Vectors Ucits Etfs Plc - ', '');+ name = name.replace('Vanguard Funds Public Limited Company - ', '');+ name = name.replace('Vanguard Index Funds - ', '');+ name = name.replace('Xtrackers (IE) Plc - ', '');+ }++ return name || aAssetProfile.price.shortName || aAssetProfile.price.symbol;+ }+private parseAssetClass(aPrice: Price): {assetClass: AssetClass;assetSubClass: AssetSubClass;