Created
November 28, 2024 13:58
-
-
Save IIvexII/25a94fd1d66709f4dcf9216a85363384 to your computer and use it in GitHub Desktop.
Share Price and Dividend Forecasting Calculator with compounding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buyAvgRate = 367.01; | |
let numberOfShares = 532; | |
const numberOfSharesForNonCompounding = 532; | |
let sharePrice = 367.01; | |
const sharePriceGrowth = 0.085; // 8% | |
let dividendPerShare = 12.5; | |
const dividendGrowthRate = 0.15; // 15% | |
let incomeTax = 0.15; // 15% income tax on dividend | |
let totalDividendPaidPerShare = 0; | |
const yearsOfHolding = 5; | |
for (let year = 1; year <= yearsOfHolding; year++) { | |
totalDividendPaidPerShare += dividendPerShare * 0.85; | |
// update the values by growth rate | |
dividendPerShare = Math.round(dividendPerShare * (1 + dividendGrowthRate)); | |
sharePrice = Math.round(sharePrice * (1 + sharePriceGrowth)); | |
// buy more shares from dividend | |
numberOfShares += Math.round(Math.ceil((dividendPerShare*0.85*numberOfShares) / sharePrice)); | |
} | |
console.log('Total Dividend/Share: ', totalDividendPaidPerShare); | |
console.log('Total Dividend: ', totalDividendPaidPerShare * numberOfShares); | |
console.log('Total Shares: ', numberOfShares); | |
console.log('Share Price: ', sharePrice); | |
console.log(`Share Price Growht(%): ${sharePrice/367.01*100}`); | |
console.log('----------------------------'); | |
console.log('Total Value of Portfolio:', numberOfShares * sharePrice ); | |
console.log('Total Value of Portfolio(without compounding):', numberOfSharesForNonCompounding * sharePrice ); | |
console.log('----------------------------'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment