Browse Source
Bugfix/fix division by zero error in dividend yield calculation (#3354)
* Handle division by zero
* Update changelog
pull/3360/head
Thomas Kaul
11 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
9 additions and
6 deletions
-
CHANGELOG.md
-
apps/api/src/app/portfolio/portfolio.service.ts
|
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed an issue in the calculation of the portfolio summary caused by future liabilities |
|
|
|
- Fixed a division by zero error in the dividend yield calculation (experimental) |
|
|
|
|
|
|
|
## 2.77.1 - 2024-04-27 |
|
|
|
|
|
|
|
|
|
@ -704,17 +704,19 @@ export class PortfolioService { |
|
|
|
|
|
|
|
const dividendYieldPercent = this.getAnnualizedPerformancePercent({ |
|
|
|
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)), |
|
|
|
netPerformancePercent: dividendInBaseCurrency.div( |
|
|
|
timeWeightedInvestment |
|
|
|
) |
|
|
|
netPerformancePercent: timeWeightedInvestment.eq(0) |
|
|
|
? new Big(0) |
|
|
|
: dividendInBaseCurrency.div(timeWeightedInvestment) |
|
|
|
}); |
|
|
|
|
|
|
|
const dividendYieldPercentWithCurrencyEffect = |
|
|
|
this.getAnnualizedPerformancePercent({ |
|
|
|
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)), |
|
|
|
netPerformancePercent: dividendInBaseCurrency.div( |
|
|
|
timeWeightedInvestmentWithCurrencyEffect |
|
|
|
) |
|
|
|
netPerformancePercent: timeWeightedInvestmentWithCurrencyEffect.eq(0) |
|
|
|
? new Big(0) |
|
|
|
: dividendInBaseCurrency.div( |
|
|
|
timeWeightedInvestmentWithCurrencyEffect |
|
|
|
) |
|
|
|
}); |
|
|
|
|
|
|
|
const historicalData = await this.dataProviderService.getHistorical( |
|
|
|