Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/add asset profile details to activities import (#1552)
Thomas Kaul15357bd5b5d1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c28574d1d1..627a7d7d14 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- Changed the execution time of the asset profile data gathering to every Sunday at lunch time+- Improved the activities import by providing asset profile details- Upgraded `@codewithdan/observable-store` from version `2.2.11` to `2.2.15`- Upgraded `bull` from version `4.8.5` to `4.10.2`- Upgraded `countup.js` from version `2.0.7` to `2.3.2`diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.tsindex ea6eea9ba6..78e857e7f7 100644--- a/apps/api/src/app/import/import.service.ts+++ b/apps/api/src/app/import/import.service.ts@@ -6,6 +6,7 @@ import { DataProviderService } from '@ghostfolio/api/services/data-provider/dataimport { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';import { OrderWithAccount } from '@ghostfolio/common/types';import { Injectable } from '@nestjs/common';+import { SymbolProfile } from '@prisma/client';import Big from 'big.js';import { endOfToday, isAfter, isSameDay, parseISO } from 'date-fns';import { v4 as uuidv4 } from 'uuid';@@ -42,7 +43,7 @@ export class ImportService {}}- await this.validateActivities({+ const assetProfiles = await this.validateActivities({activitiesDto,maxActivitiesToImport,userId@@ -104,7 +105,8 @@ export class ImportService {sectors: null,symbolMapping: null,updatedAt: undefined,- url: null+ url: null,+ ...assetProfiles[symbol]},symbolProfileId: undefined,updatedAt: new Date()@@ -172,6 +174,9 @@ export class ImportService {throw new Error(`Too many activities (${maxActivitiesToImport} at most)`);}+ const assetProfiles: {+ [symbol: string]: Partial<SymbolProfile>;+ } = {};const existingActivities = await this.orderService.orders({include: { SymbolProfile: true },orderBy: { date: 'desc' },@@ -200,22 +205,28 @@ export class ImportService {}if (dataSource !== 'MANUAL') {- const quotes = await this.dataProviderService.getQuotes([- { dataSource, symbol }- ]);+ const assetProfile = (+ await this.dataProviderService.getAssetProfiles([+ { dataSource, symbol }+ ])+ )?.[symbol];- if (quotes[symbol] === undefined) {+ if (assetProfile === undefined) {throw new Error(`activities.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`);}- if (quotes[symbol].currency !== currency) {+ if (assetProfile.currency !== currency) {throw new Error(- `activities.${index}.currency ("${currency}") does not match with "${quotes[symbol].currency}"`+ `activities.${index}.currency ("${currency}") does not match with "${assetProfile.currency}"`);}++ assetProfiles[symbol] = assetProfile;}}++ return assetProfiles;}}diff --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 01dcf79a1a..4e62b251e4 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@@ -154,11 +154,7 @@ export class YahooFinanceService implements DataProviderInterface {response.url = url;}} catch (error) {- throw new Error(- `Could not get asset profile for ${aSymbol} (${this.getName()}): [${- error.name- }] ${error.message}`- );+ Logger.error(error, 'YahooFinanceService');}return response;