diff --git a/CHANGELOG.md b/CHANGELOG.md index 60727af7b..fc8b3cb49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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 + +### Fixed + +- Fixed an issue with the currency conversion in the portfolio calculations + ## 1.31.0 - 01.08.2021 ### Added @@ -13,7 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Refactored the core engine for the calculations +- Refactored the core engine for the portfolio calculations +- Improved the performance of the portfolio calculations ## 1.30.0 - 31.07.2021 diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index bb6f403cb..47c69bda0 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -641,6 +641,7 @@ export class PortfolioService { return { transactionPoints: [], orders: [] }; } + const userCurrency = this.request.user.Settings.currency; const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({ currency: order.currency, date: format(order.date, DATE_FORMAT), @@ -648,12 +649,18 @@ export class PortfolioService { quantity: new Big(order.quantity), symbol: order.symbol, type: order.type, - unitPrice: new Big(order.unitPrice) + unitPrice: new Big( + this.exchangeRateDataService.toCurrency( + order.unitPrice, + order.currency, + userCurrency + ) + ) })); const portfolioCalculator = new PortfolioCalculator( this.currentRateService, - this.request.user.Settings.currency + userCurrency ); portfolioCalculator.computeTransactionPoints(portfolioOrders); return {