Browse Source
Bugfix/time in market of portfolio summary to be empty if no activity (#7428)
* Fix time in market if no activity
* Update changelog
pull/7420/head
Thomas Kaul
2 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
40 additions and
18 deletions
-
CHANGELOG.md
-
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
-
apps/api/src/app/portfolio/portfolio.service.ts
-
apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts
-
libs/common/src/lib/interfaces/portfolio-summary.interface.ts
|
|
|
@ -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 the time in market of the portfolio summary to be empty if there is no activity |
|
|
|
|
|
|
|
## 3.35.0 - 2026-07-27 |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
|
|
@ -816,15 +816,18 @@ export abstract class PortfolioCalculator { |
|
|
|
let firstAccountBalanceDate: Date; |
|
|
|
let firstActivityDate: Date; |
|
|
|
|
|
|
|
if (this.accountBalanceItems?.length > 0) { |
|
|
|
try { |
|
|
|
const firstAccountBalanceDateString = this.accountBalanceItems[0]?.date; |
|
|
|
const firstAccountBalanceDateString = this.accountBalanceItems[0].date; |
|
|
|
firstAccountBalanceDate = firstAccountBalanceDateString |
|
|
|
? parseDate(firstAccountBalanceDateString) |
|
|
|
: new Date(); |
|
|
|
} catch (error) { |
|
|
|
firstAccountBalanceDate = new Date(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.transactionPoints?.length > 0) { |
|
|
|
try { |
|
|
|
const firstActivityDateString = this.transactionPoints[0].date; |
|
|
|
firstActivityDate = firstActivityDateString |
|
|
|
@ -833,8 +836,19 @@ export abstract class PortfolioCalculator { |
|
|
|
} catch (error) { |
|
|
|
firstActivityDate = new Date(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const dates = [firstAccountBalanceDate, firstActivityDate].filter( |
|
|
|
(date) => { |
|
|
|
return !!date; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
if (dates.length === 0) { |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
|
|
|
|
return min([firstAccountBalanceDate, firstActivityDate]); |
|
|
|
return min(dates); |
|
|
|
} |
|
|
|
|
|
|
|
protected abstract getSymbolMetrics({ |
|
|
|
|
|
|
|
@ -1986,7 +1986,9 @@ export class PortfolioService { |
|
|
|
.minus(liabilities) |
|
|
|
.toNumber(); |
|
|
|
|
|
|
|
const daysInMarket = differenceInDays(new Date(), dateOfFirstActivity); |
|
|
|
const daysInMarket = dateOfFirstActivity |
|
|
|
? differenceInDays(new Date(), dateOfFirstActivity) |
|
|
|
: 0; |
|
|
|
|
|
|
|
const annualizedPerformancePercent = getAnnualizedPerformancePercent({ |
|
|
|
daysInMarket, |
|
|
|
|
|
|
|
@ -116,7 +116,7 @@ export class GfPortfolioSummaryComponent implements OnChanges { |
|
|
|
} |
|
|
|
); |
|
|
|
} else { |
|
|
|
this.timeInMarket = '-'; |
|
|
|
this.timeInMarket = '–'; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.timeInMarket = undefined; |
|
|
|
|
|
|
|
@ -6,7 +6,7 @@ export interface PortfolioSummary extends PortfolioPerformance { |
|
|
|
annualizedPerformancePercent: number; |
|
|
|
annualizedPerformancePercentWithCurrencyEffect: number; |
|
|
|
cash: number; |
|
|
|
dateOfFirstActivity: Date; |
|
|
|
dateOfFirstActivity?: Date; |
|
|
|
dividendInBaseCurrency: number; |
|
|
|
emergencyFund: { |
|
|
|
assets: number; |
|
|
|
|