Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/fix spike of positions with differing currency of user (#248)

Thomas94d2310217be
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f34b33a9ef..afb3b317d7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed the missing market state in the positions tab
+- Fixed the chart of positions with differing currency from user
## 1.31.1 - 01.08.2021
diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts
index 2ac5e741b8..a3e012d44c 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -300,11 +300,17 @@ export class PortfolioService {
currency,
firstBuyDate,
investment,
- marketPrice,
quantity,
transactionCount
} = position;
+ // Convert market price back to currency of position
+ const marketPrice = this.exchangeRateDataService.toCurrency(
+ position.marketPrice,
+ this.request.user.Settings.currency,
+ currency
+ );
+
const historicalData = await this.dataProviderService.getHistorical(
[aSymbol],
'day',