Skip to content

Commit 804b411

Browse files
Merge pull request #5 from introvertedspud/feature/cleanup-and-aggregateDataByYear
feat: Introduce breaking changes with aggregateDataByYear and enhance…
2 parents 0a63cdd + 6f59bee commit 804b411

27 files changed

+1135
-103
lines changed

README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,54 @@ My journey into retirement planning began with a simple realization: existing to
2525
To address these challenges, I started developing the Retirement Calculator package. It's a work in progress, and I have more exciting features in mind, but it's already a powerful tool for your retirement planning needs.
2626

2727
## Key Features
28-
- **Contribution Calculation**: Determine monthly contributions to reach a specific retirement balance.
29-
- **Withdrawal Estimation**: Find out how much you can spend from your retirement savings.
30-
- **Inflation Adjustment**: Consider the impact of inflation on your retirement planning.
28+
29+
- **Contribution Calculation**: Determine monthly contributions needed to reach your desired retirement balance.
30+
- **Withdrawal Estimation**: Understand how much you can safely spend from your retirement savings each year.
31+
- **Inflation Adjustment**: Take into account the impact of inflation on your retirement savings and planning.
32+
3133

3234
## Usage
3335

3436
### Importing the Calculator
3537

3638
```typescript
37-
import { RetirementCalculator, CONTRIBUTION_FREQUENCY } from 'retirement-calculator';
39+
import { RetirementCalculator } from 'retirement-calculator';
3840
```
39-
### Calculating Monthly Contributions
41+
### Calculating Compounding Interest With Additional Contributions
4042
```typescript
4143
const calculator = new RetirementCalculator();
42-
const contributionDetails = calculator.getContributionNeededForDesiredBalance(
43-
startingBalance,
44-
desiredBalance,
45-
years,
46-
annualInterestRate,
47-
contributionFrequency,
48-
compoundingFrequency,
49-
inflationRate
50-
);
44+
const balance = calculator.getCompoundInterestWithAdditionalContributions(1000, 100, 1, .1, 12, 12);
5145
```
5246

53-
### Calculating Compound Interest with Contributions
47+
48+
### Calculate Contributions Needed to Achieve a Desired Balance
5449
```typescript
55-
const compoundInterest = calculator.getCompoundInterestWithAdditionalContributions(
56-
initialBalance,
57-
monthlyContribution,
58-
years,
59-
annualInterestRate,
60-
contributionFrequency,
61-
compoundingFrequency
62-
);
50+
const calculator = new RetirementCalculator();
51+
const contributionsNeeded = getContributionNeededForDesiredBalance(1000,10000,10,.1,12,12);
52+
53+
// You won't necessarily hit your exact goal, so to find out what the exact total would be, run the following
54+
const balance = calculator.getCompoundInterestWithAdditionalContributions(1000, contributionsNeeded.contributionNeededPerPeriod, 10, .1, 12, 12);
6355
```
56+
57+
### Example Scenarios
58+
I have made a couple example scenarios that can be found [here](examples). This may give inspiration on how to best use this tool to plan for retirement. There is a lot more to retirement than simply plugging numbers into a compounding interest calculator.
59+
60+
#### Scenario 1
61+
Perhaps you have a starting balance in your retirement account, and want to get to the "prized" goal of $1,000,000. Calculate how well you are doing now, and where you need to be in order to achieve your goal. Also, potentially plan with inflation as this could severely impact your results. To run, use ts-node in your console.
62+
63+
Running the script will output the following:
64+
65+
![Results from scenario 1](images/example1.png)
66+
67+
#### Scenario 2
68+
Perhaps you don't know how much you want to have in retirement. Instead, you would like to be able to spend $80,000 a year in retirement and not run out of money in 30 years based on the 4% rule. You could also see what that would mean if you included inflation and wanted your $80,000 a year to go as far in 25 years as it does now. To run, use ts-node in your console.
69+
70+
Running the script will output the following:
71+
72+
![Results from scenario 2](images/example2.png)
73+
74+
More scenarios will be added as I add planned capabilities in the future.
75+
6476
## Planned Enhancements
6577
- **Detailed Periodic Reporting**: Provide a detailed breakdown of investments and interest accrued over each period, ideal for visualization.
6678
- **Fee Management**: Include functionality to account for management fees and their long-term impact.

docs/assets/highlight.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
--dark-hl-5: #569CD6;
1414
--light-hl-6: #0070C1;
1515
--dark-hl-6: #4FC1FF;
16+
--light-hl-7: #098658;
17+
--dark-hl-7: #B5CEA8;
18+
--light-hl-8: #008000;
19+
--dark-hl-8: #6A9955;
1620
--light-code-background: #FFFFFF;
1721
--dark-code-background: #1E1E1E;
1822
}
@@ -25,6 +29,8 @@
2529
--hl-4: var(--light-hl-4);
2630
--hl-5: var(--light-hl-5);
2731
--hl-6: var(--light-hl-6);
32+
--hl-7: var(--light-hl-7);
33+
--hl-8: var(--light-hl-8);
2834
--code-background: var(--light-code-background);
2935
} }
3036

@@ -36,6 +42,8 @@
3642
--hl-4: var(--dark-hl-4);
3743
--hl-5: var(--dark-hl-5);
3844
--hl-6: var(--dark-hl-6);
45+
--hl-7: var(--dark-hl-7);
46+
--hl-8: var(--dark-hl-8);
3947
--code-background: var(--dark-code-background);
4048
} }
4149

@@ -47,6 +55,8 @@
4755
--hl-4: var(--light-hl-4);
4856
--hl-5: var(--light-hl-5);
4957
--hl-6: var(--light-hl-6);
58+
--hl-7: var(--light-hl-7);
59+
--hl-8: var(--light-hl-8);
5060
--code-background: var(--light-code-background);
5161
}
5262

@@ -58,6 +68,8 @@
5868
--hl-4: var(--dark-hl-4);
5969
--hl-5: var(--dark-hl-5);
6070
--hl-6: var(--dark-hl-6);
71+
--hl-7: var(--dark-hl-7);
72+
--hl-8: var(--dark-hl-8);
6173
--code-background: var(--dark-code-background);
6274
}
6375

@@ -68,4 +80,6 @@
6880
.hl-4 { color: var(--hl-4); }
6981
.hl-5 { color: var(--hl-5); }
7082
.hl-6 { color: var(--hl-6); }
83+
.hl-7 { color: var(--hl-7); }
84+
.hl-8 { color: var(--hl-8); }
7185
pre, code { background: var(--code-background); }

docs/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)