buyer also invests monthly savings when buying is cheaper than renting

This commit is contained in:
Johannes
2026-03-20 02:25:40 +01:00
parent 8e452f484c
commit ba906bf35e

15
calc.js
View File

@@ -75,10 +75,6 @@ function run_simulation(p) {
yr_upkeep += prop_tax_m + maint_m + insurance_m; yr_upkeep += prop_tax_m + maint_m + insurance_m;
cum_buy_cost += total_buy_m; cum_buy_cost += total_buy_m;
buyer_portfolio *= (1 + invest_r_m);
const selling_costs = home_value * (p.closing_sell_pct / 100);
const buyer_nw = home_value - selling_costs - balance + buyer_portfolio;
// --- rent side --- // --- rent side ---
const renters_ins_m = p.renters_ins / 12; const renters_ins_m = p.renters_ins / 12;
const total_rent_m = monthly_rent + renters_ins_m; const total_rent_m = monthly_rent + renters_ins_m;
@@ -86,9 +82,14 @@ function run_simulation(p) {
yr_renters_ins += renters_ins_m; yr_renters_ins += renters_ins_m;
cum_rent_cost += total_rent_m; cum_rent_cost += total_rent_m;
// renter invests the difference if buying is more expensive // each side invests their monthly savings vs the other
const monthly_delta = Math.max(0, total_buy_m - total_rent_m); const rent_delta = Math.max(0, total_buy_m - total_rent_m);
portfolio = portfolio * (1 + invest_r_m) + monthly_delta; const buy_delta = Math.max(0, total_rent_m - total_buy_m);
portfolio = portfolio * (1 + invest_r_m) + rent_delta;
buyer_portfolio = buyer_portfolio * (1 + invest_r_m) + buy_delta;
const selling_costs = home_value * (p.closing_sell_pct / 100);
const buyer_nw = home_value - selling_costs - balance + buyer_portfolio;
// apply capital gains tax on portfolio gains when we "cash out" at end // apply capital gains tax on portfolio gains when we "cash out" at end
// (we track gross portfolio, deduct tax in summary) // (we track gross portfolio, deduct tax in summary)