Bugfix/fix division by zero error in dividend yield calculation (#3354)
* Handle division by zero * Update changelog
This commit is contained in:
parent
a5833566a8
commit
486de968a2
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed an issue in the calculation of the portfolio summary caused by future liabilities
|
- 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
|
## 2.77.1 - 2024-04-27
|
||||||
|
|
||||||
|
@ -704,17 +704,19 @@ export class PortfolioService {
|
|||||||
|
|
||||||
const dividendYieldPercent = this.getAnnualizedPerformancePercent({
|
const dividendYieldPercent = this.getAnnualizedPerformancePercent({
|
||||||
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
||||||
netPerformancePercent: dividendInBaseCurrency.div(
|
netPerformancePercent: timeWeightedInvestment.eq(0)
|
||||||
timeWeightedInvestment
|
? new Big(0)
|
||||||
)
|
: dividendInBaseCurrency.div(timeWeightedInvestment)
|
||||||
});
|
});
|
||||||
|
|
||||||
const dividendYieldPercentWithCurrencyEffect =
|
const dividendYieldPercentWithCurrencyEffect =
|
||||||
this.getAnnualizedPerformancePercent({
|
this.getAnnualizedPerformancePercent({
|
||||||
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
|
||||||
netPerformancePercent: dividendInBaseCurrency.div(
|
netPerformancePercent: timeWeightedInvestmentWithCurrencyEffect.eq(0)
|
||||||
timeWeightedInvestmentWithCurrencyEffect
|
? new Big(0)
|
||||||
)
|
: dividendInBaseCurrency.div(
|
||||||
|
timeWeightedInvestmentWithCurrencyEffect
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
const historicalData = await this.dataProviderService.getHistorical(
|
const historicalData = await this.dataProviderService.getHistorical(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user