Skip to main content

Real Estate vs. Equity Simulation Engine

Project description

Rent vs. Buy Simulator

Tests Coverage Linting Python 3.12+ License

Try the Live App

A financial simulation tool that compares three capital allocation strategies over time:

  • Buy — Purchase property with a mortgage
  • Rent & Invest — Rent and invest the down payment in equities
  • Rent & Invest Savings — Rent and invest monthly savings (when mortgage > rent)

Features

  • Mortgage amortization, property appreciation, equity growth, closing costs, property tax, insurance, and maintenance
  • Tax benefit modeling: mortgage interest deduction, capital gains exclusion (Section 121), SALT cap
  • Four interactive Plotly charts with breakeven analysis
  • Quick presets for common scenarios (High Interest, Bull Market, Conservative, First-Time Buyer)
  • Save, compare, and export up to 5 scenarios side-by-side
  • PDF report export with charts and configuration summary
  • Monte Carlo uncertainty analysis with stochastic simulation
  • Vectorized NumPy engine — no Python loops

Installation

From PyPI

# As a CLI tool (recommended)
uv tool install rent-vs-buy-simulator
rent-vs-buy

# Or as a library
uv pip install rent-vs-buy-simulator

From Source

git clone https://github.com/palsagar/rent-vs-buy-simulator.git
cd rent-vs-buy-simulator
uv sync
streamlit run src/simulator/app.py

Docker

# Local development
docker compose up --build
# Open http://localhost:8501

# Production
docker build -t rent-vs-buy-simulator .
docker run -p 8501:8501 rent-vs-buy-simulator

Library Usage

from simulator import SimulationConfig, calculate_scenarios

config = SimulationConfig(
    duration_years=30,
    property_price=500000,
    down_payment_pct=20,
    mortgage_rate_annual=4.5,
    property_appreciation_annual=3.0,
    equity_growth_annual=7.0,
    monthly_rent=2000,
    rent_inflation_rate=0.03,
)

results = calculate_scenarios(config)
print(f"Buy: ${results.final_net_buy:,.0f}")
print(f"Rent & Invest: ${results.final_net_rent:,.0f}")
print(f"Difference: ${results.final_difference:,.0f}")

Contributing

Contributions welcome! Fork the repo, create a feature branch, and open a PR against main.

uv sync
uv run pytest tests/ --cov --cov-report=term   # 80% coverage minimum
uv run ruff check src/ tests/

See FORMULAS.md for the mathematical reference.

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rent_vs_buy_simulator-1.0.0.tar.gz (171.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rent_vs_buy_simulator-1.0.0-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file rent_vs_buy_simulator-1.0.0.tar.gz.

File metadata

  • Download URL: rent_vs_buy_simulator-1.0.0.tar.gz
  • Upload date:
  • Size: 171.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rent_vs_buy_simulator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 426b0eaf7191aecb3374baaefc91053320fbab248be74c9091df563eec19f253
MD5 4a64a9478d2b8fa88398f28e330b457c
BLAKE2b-256 0f3d86e169f92204c97cc076839df2ef66ced10f88499ab21ab38a97867a12f4

See more details on using hashes here.

File details

Details for the file rent_vs_buy_simulator-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rent_vs_buy_simulator-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rent_vs_buy_simulator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daf9b7ed8f0a1a53e17345d78ec2ea5503de56dd6719c772aaecfa040230e3fa
MD5 cfaa1837af0d0efb55f431dbed19d355
BLAKE2b-256 69cf82e8cb4d27b86d50cd72b17e89818e6bcf2f1409020ed8fc365c828de1a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page