Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/add safe withdrawal rate to user settings (#5629)
Thomas Kaul6ff1d65a7092
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8ddf62e812..36d4cbec20 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,16 @@ 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++### Added++- Added the safe withdrawal rate to the user settings (experimental)++### Changed++- Improved the wording of the 4% rule in the _FIRE_ section+## 2.203.0 - 2025-09-27### Addeddiff --git a/apps/api/src/app/user/update-user-setting.dto.ts b/apps/api/src/app/user/update-user-setting.dto.tsindex b34b6fae23..3ee59f7ddb 100644--- a/apps/api/src/app/user/update-user-setting.dto.ts+++ b/apps/api/src/app/user/update-user-setting.dto.ts@@ -104,6 +104,10 @@ export class UpdateUserSettingDto {@IsOptional()retirementDate?: string;+ @IsNumber()+ @IsOptional()+ safeWithdrawalRate?: number;+@IsNumber()@IsOptional()savingsRate?: number;diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.tsindex 6512fbbc2f..f797270ff9 100644--- a/apps/api/src/app/user/user.service.ts+++ b/apps/api/src/app/user/user.service.ts@@ -265,6 +265,11 @@ export class UserService {PerformanceCalculationType.ROAI;}+ // Set default value for safe withdrawal rate+ if (!(user.settings.settings as UserSettings)?.safeWithdrawalRate) {+ (user.settings.settings as UserSettings).safeWithdrawalRate = 0.04;+ }+// Set default value for view modeif (!(user.settings.settings as UserSettings).viewMode) {(user.settings.settings as UserSettings).viewMode = 'DEFAULT';diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts b/apps/client/src/app/pages/portfolio/fire/fire-page.component.tsindex 83650d9cac..ab0fbc7875 100644--- a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts+++ b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts@@ -63,7 +63,10 @@ export class GfFirePageComponent implements OnDestroy, OnInit {this.fireWealth = new Big(10000);}- this.withdrawalRatePerYear = this.fireWealth.mul(4).div(100);+ this.withdrawalRatePerYear = this.fireWealth.mul(+ this.user.settings.safeWithdrawalRate+ );+this.withdrawalRatePerMonth = this.withdrawalRatePerYear.div(12);this.isLoading = false;diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.html b/apps/client/src/app/pages/portfolio/fire/fire-page.htmlindex 77fd1640cf..dd29dbcc86 100644--- a/apps/client/src/app/pages/portfolio/fire/fire-page.html+++ b/apps/client/src/app/pages/portfolio/fire/fire-page.html@@ -37,7 +37,7 @@</div><div><h4 class="align-items-center d-flex">- <span i18n>4% Rule</span>+ <span i18n>Sustainable retirement income</span>@if (user?.subscription?.type === 'Basic') {<gf-premium-indicator class="ml-1" />}@@ -96,7 +96,15 @@[value]="fireWealth?.toNumber()"/></span>- and a withdrawal rate of 4%.+ and a safe withdrawal rate (SWR) of+ <span class="font-weight-bold"+ ><gf-value+ class="d-inline-block"+ [isPercent]="true"+ [locale]="user?.settings?.locale"+ [precision]="1"+ [value]="user?.settings?.safeWithdrawalRate" /></span+ >.</div>}</div>diff --git a/libs/common/src/lib/interfaces/user-settings.interface.ts b/libs/common/src/lib/interfaces/user-settings.interface.tsindex e5c65f82d7..65325a42f8 100644--- a/libs/common/src/lib/interfaces/user-settings.interface.ts+++ b/libs/common/src/lib/interfaces/user-settings.interface.ts@@ -29,6 +29,7 @@ export interface UserSettings {performanceCalculationType?: PerformanceCalculationType;projectedTotalAmount?: number;retirementDate?: string;+ safeWithdrawalRate?: number;savingsRate?: number;viewMode?: ViewMode;xRayRules?: XRayRulesSettings;