Skip to content

About

A financial simulation tool built to compare the long-term net worth impact of renting and investing versus purchasing real estate in the Zurich market.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

🏠 Zurich Wealth Engine

Should you buy or rent in Zurich? Calculate which option makes you richer in the long term.

Visit Site   GitHub


Buying a home is one of the biggest financial decisions most of us will ever make. But when thinking about how a purchase will affect your financial future, many people focus on which home to buy while overlooking a more fundamental question:

Should I buy at all in Zurich?

This calculator answers that question by modeling how buying vs. renting affects your net worth over time—accounting for Swiss-specific tax rules like Eigenmietwert, property gains tax, and mandatory mortgage amortization.


🎯 Features

  • 🏠 Long-term impact: Compare true wealth accumulation, not just monthly costs
  • 📊 Data-driven decisions: Interactive charts showing net worth and cash flow over time
  • 💰 Opportunity cost: Understand what you gain or lose by tying up money in a home vs. investing
  • 📈 Compound interest calculator: Also works as a standalone investment growth calculator
  • 🇨🇭 Swiss-specific: Eigenmietwert taxation, Zurich property gains tax, Swiss mortgage rules
  • 🎯 Personalized results: Input your specific situation and financial assumptions

No sign-up, no ads, no data stored—just instant, transparent math.


🖥️ How to Use

Step 1: Choose Your Time Horizon

Select how far into the future you want to project (10, 15, 20, 30, or 50 years).

Step 2: Configure Your "Buy" Scenario

  • 🏠 Property details: Purchase price, down payment percentage (min 20% in Switzerland)
  • 💰 Mortgage: Interest rate (Swiss SARON-based rates)
  • 📈 Growth: Expected annual property appreciation for Zurich
  • 🏦 Swiss rules: Automatic amortization to 66.6% LTV over 15 years

Step 3: Configure Your "Rent & Invest" Scenario

  • 🏠 Rental details: Monthly rent and expected annual increases
  • 📊 Investment plan: Choose SMI, S&P 500, Nasdaq, or set custom returns
  • 💸 Tax advantage: Switzerland has no capital gains tax on securities

Step 4: Review Your Results

  • Winner Banner: See which scenario leaves you wealthier and by how much
  • Net Worth Chart: Visualize wealth accumulation over time
  • Cash Outflow Chart: Understand where your money actually goes
  • Summary Cards: Detailed breakdown of each scenario

✨ The Calculation Method

Starting Point — Fair Comparison

Both scenarios begin with the same initial capital:

Scenario What happens to your capital
Buy Down payment goes to property; excess (if any) is invested
Rent All capital is invested in the market

Max Home Price = Initial Capital ÷ Down Payment %

Example: With CHF 300,000 capital and 20% down payment:

  • Max Home Price = 300,000 ÷ 0.20 = CHF 1,500,000
  • Down Payment = CHF 300,000 (all capital used for property)
  • Renter invests all CHF 300,000

Core Logic

Same money in, see who ends up richer.

  1. Equal spending baseline Each year we total what you spend under each path.

  2. Invest the difference Whenever one path costs less, the savings go into an investment bucket. This ensures both options have the same actual spending.

  3. End-of-game tally After your chosen horizon:

    • Sell the property (minus Zurich property gains tax)
    • Cash out investments (tax-free in Switzerland)
    • Pay off remaining mortgage

The bigger pile wins.

Swiss-Specific Calculations

Feature Description
Eigenmietwert 70% of market rent added to taxable income, offset by mortgage interest deductions
Property Gains Tax Up to 35% base rate in Zurich, with discounts up to 50% for 20+ year holdings
Amortization Mandatory reduction to 66.6% LTV within 15 years
Down Payment Minimum 20% required (10% must be "hard" equity)
Investment Tax No capital gains tax on securities in Switzerland

📝 Key Assumptions

The calculator includes these factors for accuracy:

  • ✅ Mortgage amortization: Swiss indirect amortization schedule
  • ✅ Eigenmietwert: Imputed rental value taxation with deductions
  • ✅ Compound growth: Property appreciation and investment returns
  • ✅ Real-world costs: Maintenance (1%/year), transaction costs
  • ✅ Property gains tax: Zurich-specific rates with holding period discounts
  • ✅ Fair comparison: Both scenarios spend the same total amount

All calculations run entirely in your browser—no data is sent anywhere.


🚀 Development

Local Setup

# Clone the repository
git clone https://github.com/albertocutone/wealth-engine.git
cd wealth-engine

# Serve locally (any static server works)
python3 -m http.server 8080
# or
npx serve

Open http://localhost:8080 in your browser.

🧪 Running Tests

The project includes a comprehensive test suite for validating calculation accuracy. Tests run in the browser using a lightweight, dependency-free test runner.

# Start a local server (required for ES6 modules)
python3 -m http.server 8080
# or
npx serve

Then open http://localhost:8080/tests/ in your browser.

Test Coverage:

  • ✅ Simulation calculations: Down payment, mortgage, property appreciation, rent increases
  • ✅ Swiss-specific logic: Eigenmietwert tax, property gains tax with holding period discounts
  • ✅ Investment calculations: Compound returns, monthly contributions, budget matching
  • ✅ Formatting functions: Currency (CHF), numbers, percentages
  • ✅ Edge cases: Zero values, maximum ranges, long simulation periods

Test Files:

File Description
tests/simulation.test.js Core simulation and calculation tests
tests/formatting.test.js Currency, number, and percentage formatting tests
tests/test-runner.js Lightweight test framework (no dependencies)
tests/index.html Browser-based test runner UI

🏗️ Project Structure

wealth-engine/
├── index.html          # Main application page
├── css/
│   └── styles.css      # All styling (CSS custom properties)
├── js/
│   ├── app.js          # UI controller & event handling
│   ├── chart.js        # Chart.js configuration
│   ├── config.js       # Swiss-specific parameters
│   └── simulation.js   # Core financial calculations
├── tests/
│   ├── index.html      # Test runner UI
│   ├── index.js        # Test entry point
│   ├── test-runner.js  # Lightweight test framework
│   ├── simulation.test.js  # Simulation calculation tests
│   └── formatting.test.js  # Formatting function tests
├── assets/
│   └── favicon.svg     # Site icon
├── LICENSE             # MIT License
└── README.md           # This file

🛠️ Tech Stack

Layer Technology
Frontend Vanilla JavaScript (ES6 Modules)
Styling Custom CSS with CSS Variables
Charts Chart.js
Icons Font Awesome
Hosting GitHub Pages

Key Design Decisions

  • No build step: Pure HTML/CSS/JS for simplicity and transparency
  • ES6 Modules: Clean separation of concerns
  • URL State: Share results via URL parameters
  • Mobile-first: Responsive design for all devices

🔮 Roadmap

  • Canton Presets: Add presets for Zug, Schwyz, Geneva, etc.
  • Pillar 3a Integration: Model pension fund withdrawals for down payment
  • PDF Export: Generate detailed comparison reports
  • Advanced Charts: Monthly cash flow breakdown
  • Shareable Links: Share results with URL parameters
  • Cash-out Mode: Include selling costs and property gains tax

🤝 Contributing

Contributions are welcome! Ideas for improvement:

  • Add support for other Swiss cantons with different tax rules
  • Integrate 2nd and 3rd pillar pension withdrawal logic
  • Add rental deposit opportunity cost
  • Improve mobile experience

To contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


⚠️ Disclaimer

This tool provides estimates for educational purposes only. It uses simplified assumptions and historical averages. Real estate and investment decisions involve significant risk and complexity.

Always consult with:

  • A qualified financial advisor
  • A Swiss tax professional
  • A mortgage specialist

before making real estate decisions.



Built with ❤️ for the Zurich housing market. If you find this useful, consider giving it a ⭐

About

A financial simulation tool built to compare the long-term net worth impact of renting and investing versus purchasing real estate in the Zurich market.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages