diff --git a/CHANGELOG.md b/CHANGELOG.md index 13f3cf93b..ebe008da7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,32 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## 1.127.0 - 16.03.2022 + +### Changed + +- Improved the error handling in the scraper configuration + +### Fixed + +- Fixed the support for multiple symbols of the data source `GHOSTFOLIO` + +## 1.126.0 - 14.03.2022 + +### Added + +- Added support for bonds + +### Changed + +- Restructured the portfolio summary tab on the home page +- Improved the tooltips in the portfolio proportion chart component by introducing multilines + +### Todo + +- Apply data migration (`yarn database:migrate`) + +## 1.125.0 - 12.03.2022 ### Added diff --git a/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts b/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts index 35c53bc7a..fb4df11e8 100644 --- a/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts +++ b/apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts @@ -50,16 +50,18 @@ export class GhostfolioScraperApiService implements DataProviderInterface { const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles( [symbol] ); - const scraperConfiguration = symbolProfile?.scraperConfiguration; + const { selector, url } = symbolProfile.scraperConfiguration; - const get = bent(scraperConfiguration?.url, 'GET', 'string', 200, {}); + if (selector === undefined || url === undefined) { + return {}; + } + + const get = bent(url, 'GET', 'string', 200, {}); const html = await get(); const $ = cheerio.load(html); - const value = this.extractNumberFromString( - $(scraperConfiguration?.selector).text() - ); + const value = this.extractNumberFromString($(selector).text()); return { [symbol]: { @@ -82,33 +84,42 @@ export class GhostfolioScraperApiService implements DataProviderInterface { public async getQuotes( aSymbols: string[] ): Promise<{ [symbol: string]: IDataProviderResponse }> { + const response: { [symbol: string]: IDataProviderResponse } = {}; + if (aSymbols.length <= 0) { - return {}; + return response; } try { - const [symbol] = aSymbols; - const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles( - [symbol] + const symbolProfiles = await this.symbolProfileService.getSymbolProfiles( + aSymbols ); - const { marketPrice } = await this.prismaService.marketData.findFirst({ + const marketData = await this.prismaService.marketData.findMany({ + distinct: ['symbol'], orderBy: { date: 'desc' }, + take: aSymbols.length, where: { - symbol + symbol: { + in: aSymbols + } } }); - return { - [symbol]: { - marketPrice, - currency: symbolProfile?.currency, + for (const symbolProfile of symbolProfiles) { + response[symbolProfile.symbol] = { + currency: symbolProfile.currency, dataSource: this.getName(), + marketPrice: marketData.find((marketDataItem) => { + return marketDataItem.symbol === symbolProfile.symbol; + }).marketPrice, marketState: MarketState.delayed - } - }; + }; + } + + return response; } catch (error) { Logger.error(error, 'GhostfolioScraperApiService'); } 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.ts index 95a14c1ab..ef4328fc8 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 @@ -21,6 +21,7 @@ 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'; @Injectable() export class YahooFinanceService implements DataProviderInterface { @@ -303,7 +304,7 @@ export class YahooFinanceService implements DataProviderInterface { return { items }; } - private parseAssetClass(aPrice: any): { + private parseAssetClass(aPrice: Price): { assetClass: AssetClass; assetSubClass: AssetSubClass; } { diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html index 5335b77a7..5206aaedc 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html @@ -119,7 +119,7 @@