Skip to content

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

Bugfix/expand date range to cover full day in exchange rate calculation (#6311)

Thomas Kaule361f093987a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e6feba4a6..bb32902f0a 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 an issue in the annualized performance calculation
+- Fixed an issue with the exchange rate calculation by expanding the date range to cover the full day (start to end of day)
## 2.237.0 - 2026-02-08
diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
index 2e58a4ef5e..553cb8c903 100644
--- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
+++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
@@ -53,6 +53,7 @@ import {
isBefore,
isWithinInterval,
min,
+ startOfDay,
startOfYear,
subDays
} from 'date-fns';
@@ -162,8 +163,8 @@ export abstract class PortfolioCalculator {
subDays(dateOfFirstActivity, 1)
);
- this.endDate = endDate;
- this.startDate = startDate;
+ this.endDate = endOfDay(endDate);
+ this.startDate = startOfDay(startDate);
this.computeTransactionPoints();
@@ -236,7 +237,7 @@ export abstract class PortfolioCalculator {
const exchangeRatesByCurrency =
await this.exchangeRateDataService.getExchangeRatesByCurrency({
currencies: Array.from(new Set(Object.values(currencies))),
- endDate: endOfDay(this.endDate),
+ endDate: this.endDate,
startDate: this.startDate,
targetCurrency: this.currency
});