如何计算加上通货膨胀的投资回报率



我想问一个比我更熟练的人。我需要计算投资回报率,但我需要加上每年的通货膨胀率。

示例:我购买了一些可以产生/节省资金的资产(太阳能/工作用汽车/工具(。该资产的购买价格为20000美元,每年产生2350美元。在简单模型中,资产在8,5年内还清(20000/2350(,但不计入平均每年3%的通货膨胀。我试图找到一个解决方案,但我只能在第一年找到它,因为第二年的计算不是从2350美元开始,而是从2420美元(2350+3%(开始,以此类推…所需的结果是计算通货膨胀调整后的回报年数

到目前为止我的努力:

<script>
let price = 20000;
let gain_year = 2350; 
let inflation = 3;

$: return_in_years = price /gain_year;

// this is only for the first year
// $: inflation_calc = (gain_year/100)*inflation;

</script>
<label for="gain_year">Gain in one year</label>
<input id="gain_year" type="number" bind:value={gain_year} />
<label for="price">Price</label>
<input id="price" type="number" bind:value={price} />
<label for="inflation">Inflation</label>
<input id="inflation" type="number" bind:value={inflation} />
<div>
Return in how many years: {return_in_years.toFixed(1)}
</div>

谢谢你们抽出时间。

我不是金融专家,但我认为这可能对你有用。请仅应用此处的概念。您的实际代码看起来与此不同。

// your inputs
let price = 20000;
let gain_year = 2350; 
let inflation = 3;
// result in years
let years = 0;
// loop for each year until the invesment is returned
while (price > 0){
// apply inflation except the first year
if (years > 0) gain_year += gain_year * inflation/100;
// price is more than gain this year
if (price >= gain_year){
// update full year and price according to the gain this year
years++;
price -= gain_year;
}
// price is less than gain this year
else {
// update year according to the portion of the price and gain this year
years += price / gain_year;
// set price to 0 so it ends
price = 0;
}
// result
console.log(price, years, gain_year);
}

您应该创建一个循环,运行您想要计算的通货膨胀年数。在循环中,像现在一样对第一年的通货膨胀率进行正常计算,但每次在循环结束前用结果更新gain_year变量。下次运行循环时,它将在计算中使用上次运行循环的结果。

最新更新