Skip to content

feat(analysis): sensitivity analysis table — rent, vacancy, rate scenarios #363

Description

@paruff

Problem

A top 0.1% investor always asks: "What if rent drops 5%? Vacancy hits 8%? Rates rise 100bps?" Currently prei shows a single-point analysis. No sensitivity modeling means investors can't stress-test deals.

Solution

Add a sensitivity analysis view for each property. Show a matrix table varying 3 inputs (rent, vacancy, interest rate) and showing resulting CoC, DSCR, and IRR for each combination.

Acceptance Criteria

  • Create core/services/sensitivity.py with run_sensitivity(property, base_values, scenarios) -> dict
  • Add view /properties/<pk>/sensitivity/ rendering the sensitivity matrix
  • Create templates/properties/sensitivity.html with a data table
  • Vary rent: -5%, 0%, +5% of base
  • Vary vacancy: 5%, 8%, 12%
  • Vary interest rate: base, +100bps, +200bps
  • Show CoC, DSCR, IRR for each of the 27 combinations (3x3x3)
  • Highlight scenarios where DSCR < 1.25 (red flag for lenders)
  • Add link from property detail view to sensitivity analysis
  • E2E test: navigate to sensitivity view, verify table renders with 27 rows
  • Unit tests for sensitivity calculation logic

Technical Notes

  • Base values come from the property's InvestmentAnalysis record
  • Use existing investor_app/finance/utils.py functions (noi, cap_rate, cash_on_cash, dscr, irr)
  • All calculations use Decimal (repo rule)
  • Table is server-rendered (no JS framework needed)
  • Color-code cells: green (good), yellow (marginal), red (fails DSCR)

Implementation Guide (for opencode/mimo v2.5)

  1. Create core/services/sensitivity.py — generate scenario combinations, call finance functions
  2. Add sensitivity_view to core/views/__init__.py
  3. Add URL pattern properties/<int:pk>/sensitivity/
  4. Create templates/properties/sensitivity.html — table with conditional CSS classes
  5. Add "Sensitivity Analysis" button to property detail template
  6. Tests in tests/test_sensitivity.py

Dependencies

  • Requires: Property with InvestmentAnalysis data
  • Enhances: Underwriting confidence

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2:analysisPhase 2: Pro-Level AnalysisenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions