From ba906bf35e940e51b7b7a0cc4621fa2dd6c81d27 Mon Sep 17 00:00:00 2001 From: Johannes Date: Fri, 20 Mar 2026 02:25:40 +0100 Subject: [PATCH] buyer also invests monthly savings when buying is cheaper than renting --- calc.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/calc.js b/calc.js index b3737d2..f975370 100644 --- a/calc.js +++ b/calc.js @@ -75,20 +75,21 @@ function run_simulation(p) { yr_upkeep += prop_tax_m + maint_m + insurance_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 --- const renters_ins_m = p.renters_ins / 12; const total_rent_m = monthly_rent + renters_ins_m; - yr_rent += monthly_rent; + yr_rent += monthly_rent; 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 - const monthly_delta = Math.max(0, total_buy_m - total_rent_m); - portfolio = portfolio * (1 + invest_r_m) + monthly_delta; + // each side invests their monthly savings vs the other + const rent_delta = Math.max(0, total_buy_m - total_rent_m); + 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 // (we track gross portfolio, deduct tax in summary)