From d32dd5e8605ad4a8bdb1833d9348a7b464460921 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:16:20 +0100 Subject: [PATCH 1/4] Feature/upgrade countries list to version 3.1.0 (#3131) * Upgrade countries-list to version 3.1.0 * Update changelog --- CHANGELOG.md | 4 ++++ .../data-enhancer/trackinsight/trackinsight.service.ts | 9 ++++----- .../services/symbol-profile/symbol-profile.service.ts | 5 ++--- package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b641f7f..f7ca1dc34 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 - Extended the content of the _Self-Hosting_ section by available home server systems on the Frequently Asked Questions (FAQ) page +### Changed + +- Upgraded `countries-list` from version `2.6.1` to `3.1.0` + ### Fixed - Fixed an issue in the performance calculation caused by multiple `SELL` activities on the same day diff --git a/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts b/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts index 63d785253..ddc3d79f8 100644 --- a/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts +++ b/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts @@ -5,12 +5,12 @@ import { Sector } from '@ghostfolio/common/interfaces/sector.interface'; import { Injectable } from '@nestjs/common'; import { SymbolProfile } from '@prisma/client'; +import { countries } from 'countries-list'; import got from 'got'; @Injectable() export class TrackinsightDataEnhancerService implements DataEnhancerInterface { private static baseUrl = 'https://www.trackinsight.com/data-api'; - private static countries = require('countries-list/dist/countries.json'); private static countriesMapping = { 'Russian Federation': 'Russia' }; @@ -131,20 +131,19 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { (response.countries as unknown as Country[]).length === 0 ) { response.countries = []; + for (const [name, value] of Object.entries( holdings?.countries ?? {} )) { let countryCode: string; - for (const [key, country] of Object.entries( - TrackinsightDataEnhancerService.countries - )) { + for (const [code, country] of Object.entries(countries)) { if ( country.name === name || country.name === TrackinsightDataEnhancerService.countriesMapping[name] ) { - countryCode = key; + countryCode = code; break; } } diff --git a/apps/api/src/services/symbol-profile/symbol-profile.service.ts b/apps/api/src/services/symbol-profile/symbol-profile.service.ts index a87b00d95..751feda22 100644 --- a/apps/api/src/services/symbol-profile/symbol-profile.service.ts +++ b/apps/api/src/services/symbol-profile/symbol-profile.service.ts @@ -189,9 +189,8 @@ export class SymbolProfileService { return { code, weight, - continent: - continents[countries[code as string]?.continent] ?? UNKNOWN_KEY, - name: countries[code as string]?.name ?? UNKNOWN_KEY + continent: continents[countries[code]?.continent] ?? UNKNOWN_KEY, + name: countries[code]?.name ?? UNKNOWN_KEY }; }); } diff --git a/package.json b/package.json index ddd5de1cf..5b92172e4 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "class-validator": "0.14.0", "color": "4.2.3", "countries-and-timezones": "3.4.1", - "countries-list": "2.6.1", + "countries-list": "3.1.0", "countup.js": "2.3.2", "date-fns": "2.29.3", "envalid": "7.3.1", diff --git a/yarn.lock b/yarn.lock index f71e7ad80..ba7e811ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9739,10 +9739,10 @@ countries-and-timezones@3.4.1: resolved "https://registry.yarnpkg.com/countries-and-timezones/-/countries-and-timezones-3.4.1.tgz#0ec2540f57e42f0f740eb2acaede786043347fe1" integrity sha512-INeHGCony4XUUR8iGL/lmt9s1Oi+n+gFHeJAMfbV5hJfYeDOB8JG1oxz5xFQu5oBZoRCJe/87k1Vzue9DoIauA== -countries-list@2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/countries-list/-/countries-list-2.6.1.tgz#d479757ac873b1e596ccea0a925962d20396c0cb" - integrity sha512-jXM1Nv3U56dPQ1DsUSsEaGmLHburo4fnB7m+1yhWDUVvx5gXCd1ok/y3gXCjXzhqyawG+igcPYcAl4qjkvopaQ== +countries-list@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/countries-list/-/countries-list-3.1.0.tgz#1cbe32f58659c7d6a1e744917689f24c84333ea8" + integrity sha512-HpTBLZba1VPTZSjUnUwR7SykxV7Z/7/+ZM5x5wi5tO99Qvom6bE2SC+AQ18016ujg3jSlYBbMITrHNnPAHSM9Q== countup.js@2.3.2: version "2.3.2" From e792924606dd98849008855c9320ff3f7eacf35d Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:15:32 +0100 Subject: [PATCH 2/4] Update OSS friends (#3132) --- apps/client/src/assets/oss-friends.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/client/src/assets/oss-friends.json b/apps/client/src/assets/oss-friends.json index 73674e8dd..cbbbd5987 100644 --- a/apps/client/src/assets/oss-friends.json +++ b/apps/client/src/assets/oss-friends.json @@ -1,5 +1,5 @@ { - "createdAt": "2024-02-29T00:00:00.000Z", + "createdAt": "2024-03-11T00:00:00.000Z", "data": [ { "name": "Aptabase", @@ -8,7 +8,7 @@ }, { "name": "Argos", - "description": "Argos provides the developer tools to debug tests and detect visual regressions..", + "description": "Argos provides the developer tools to debug tests and detect visual regressions.", "href": "https://argos-ci.com" }, { From 59c064e3c8ccfcbe0b6f2b9cbbcd28586f40c904 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:15:55 +0100 Subject: [PATCH 3/4] Feature/upgrade yahoo finance2 to version 2.10.0 (#3127) * Upgrade yahoo-finance2 to version 2.10.0 * Update changelog --- CHANGELOG.md | 1 + package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ca1dc34..242dd9dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Upgraded `countries-list` from version `2.6.1` to `3.1.0` +- Upgraded `yahoo-finance2` from version `2.9.1` to `2.10.0` ### Fixed diff --git a/package.json b/package.json index 5b92172e4..bdac1e9b1 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,7 @@ "svgmap": "2.6.0", "twitter-api-v2": "1.14.2", "uuid": "9.0.1", - "yahoo-finance2": "2.9.1", + "yahoo-finance2": "2.10.0", "zone.js": "0.14.3" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index ba7e811ef..8cf31c64b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19242,10 +19242,10 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yahoo-finance2@2.9.1: - version "2.9.1" - resolved "https://registry.yarnpkg.com/yahoo-finance2/-/yahoo-finance2-2.9.1.tgz#43e22465403f48c688ff8e762f3894aac8014d70" - integrity sha512-s+i5arE6+zUwHRJnze4EsU5aCTmsMFKFeBc9sMzSceDOjH+BSeEZG9twMYtWlSCjKbWLCmUEUCxtH1fvcq+f6Q== +yahoo-finance2@2.10.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yahoo-finance2/-/yahoo-finance2-2.10.0.tgz#90a9d7984e3b35a11fff9850c55d1cd322ddbee3" + integrity sha512-yKHjMEnFVkgIvgyxjsNAMLf4xGCKM+HzThorCNuCoE71yoie75lR+WTd0HshdCnb8tpsCclFaP045I+p6Mu6aA== dependencies: "@types/tough-cookie" "^4.0.2" ajv "8.10.0" From 7a364472c83662f770f9c319e1040590146dea2f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:16:56 +0100 Subject: [PATCH 4/4] Bugfix/fix liability issue in allocations (#3133) * Remove liabilities from allocations calculation * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/portfolio/portfolio.controller.ts | 7 +++++-- apps/api/src/app/portfolio/portfolio.service.ts | 4 ++-- .../home-summary/home-summary.component.ts | 2 +- apps/client/src/app/services/data.service.ts | 12 ++++++++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 242dd9dfe..2fddca32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed an issue in the performance calculation caused by multiple `SELL` activities on the same day +- Fixed an issue in the calculation on the allocations page caused by liabilities ## 2.62.0 - 2024-03-09 diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 748850204..557e8a5f5 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -76,8 +76,11 @@ export class PortfolioController { @Query('accounts') filterByAccounts?: string, @Query('assetClasses') filterByAssetClasses?: string, @Query('range') dateRange: DateRange = 'max', - @Query('tags') filterByTags?: string + @Query('tags') filterByTags?: string, + @Query('withLiabilities') withLiabilitiesParam = 'false' ): Promise { + const withLiabilities = withLiabilitiesParam === 'true'; + let hasDetails = true; let hasError = false; const hasReadRestrictedAccessPermission = @@ -101,8 +104,8 @@ export class PortfolioController { dateRange, filters, impersonationId, + withLiabilities, userId: this.request.user.id, - withLiabilities: true, withSummary: true }); diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 9880abcc4..74d7b382a 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -146,8 +146,7 @@ export class PortfolioService { filters, withExcludedAccounts, impersonationId: userId, - userId: this.request.user.id, - withLiabilities: true + userId: this.request.user.id }) ]); @@ -393,6 +392,7 @@ export class PortfolioService { }); const holdings: PortfolioDetails['holdings'] = {}; + const totalValueInBaseCurrency = currentPositions.currentValueInBaseCurrency.plus( cashDetails.balanceInBaseCurrency diff --git a/apps/client/src/app/components/home-summary/home-summary.component.ts b/apps/client/src/app/components/home-summary/home-summary.component.ts index b67b67ce5..bb68a4627 100644 --- a/apps/client/src/app/components/home-summary/home-summary.component.ts +++ b/apps/client/src/app/components/home-summary/home-summary.component.ts @@ -102,7 +102,7 @@ export class HomeSummaryComponent implements OnDestroy, OnInit { this.isLoading = true; this.dataService - .fetchPortfolioDetails() + .fetchPortfolioDetails({ withLiabilities: true }) .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(({ summary }) => { this.summary = summary; diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts index 7741fd601..0c8781eb1 100644 --- a/apps/client/src/app/services/data.service.ts +++ b/apps/client/src/app/services/data.service.ts @@ -390,13 +390,21 @@ export class DataService { } public fetchPortfolioDetails({ - filters + filters, + withLiabilities = false }: { filters?: Filter[]; + withLiabilities?: boolean; } = {}): Observable { + let params = this.buildFiltersAsQueryParams({ filters }); + + if (withLiabilities) { + params = params.append('withLiabilities', withLiabilities); + } + return this.http .get('/api/v1/portfolio/details', { - params: this.buildFiltersAsQueryParams({ filters }) + params }) .pipe( map((response) => {