API Reference¶
dscr-ratio exposes four free functions. All take and return f64 (and one
u32 term). No structs, no traits to implement, no features to enable.
dscr¶
Debt service coverage ratio = NOI ÷ annual debt service.
- Returns
0.0whenannual_debt_service <= 0.0(avoids division by zero). noiis annual net operating income (rent minus operating expenses, before debt service and before taxes).
use dscr_ratio::dscr;
assert!((dscr(24_000.0, 20_000.0) - 1.2).abs() < 1e-9);
assert!((dscr(20_000.0, 20_000.0) - 1.0).abs() < 1e-9); // break-even
assert_eq!(dscr(100_000.0, 0.0), 0.0); // no debt → 0
monthly_payment¶
Monthly payment on a fully-amortizing fixed-rate loan (the standard US mortgage amortization formula).
annual_rateis the nominal annual rate (e.g.0.07for 7%); it is divided by 12 internally.monthsis the loan term in months (360= 30 years).- Returns
0.0whenmonths == 0. - When
annual_rate == 0.0, returns the straight-lineprincipal / months.
$$ M = P \cdot \frac{r(1+r)^n}{(1+r)^n - 1} \quad\text{where}\quad r = \frac{\text{annual rate}}{12},\;\; n = \text{months} $$
use dscr_ratio::monthly_payment;
// $100k, 7%, 30y → ≈ $665.30/mo
let m = monthly_payment(100_000.0, 0.07, 360);
assert!((m - 665.30).abs() < 0.1);
annual_debt_service¶
Annual debt service from a monthly payment — simply monthly * 12.0.
This is the denominator of dscr.
use dscr_ratio::{monthly_payment, annual_debt_service};
let debt = annual_debt_service(monthly_payment(100_000.0, 0.07, 360));
// ≈ 7,983.61
verdict¶
Plain-language verdict for a DSCR value, matching common DSCR lender thresholds:
| DSCR range | Return value | Meaning |
|---|---|---|
ratio < 1.00 |
"fail" |
Rent does not cover debt. |
1.00 ≤ r < 1.15 |
"marginal" |
Barely covers debt. |
1.15 ≤ r < 1.25 |
"tight" |
Meets most minimums. |
1.25 ≤ r < 1.35 |
"good" |
Best-terms threshold for most lenders. |
ratio ≥ 1.35 |
"strong" |
Comfortable cushion, best pricing. |
use dscr_ratio::verdict;
assert_eq!(verdict(0.9), "fail");
assert_eq!(verdict(1.1), "marginal");
assert_eq!(verdict(1.2), "tight");
assert_eq!(verdict(1.3), "good");
assert_eq!(verdict(1.5), "strong");
Verdict vs. lender policy
These buckets reflect the most common DSCR lender thresholds, but every lender sets its own cutoffs and overlays. For a quote on a specific deal, run the numbers through the DSCRRadar DSCR loan calculator.