property.rental-yield Unreviewed
Gross and net rental yield of a let property, in basis points, from annual rent, costs and value.
1.0.1 · published 2026-10-03 by charlie · Anterra
Pinned by 14 tests, run in TypeScript, Python and Rust.
Unreviewed. This capability’s implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified conveyancer or tax adviser has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.
Not professional advice. This capability calculates property figures from published rules. It is a software component for developers, not legal or financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed in its README, and have a conveyancer or tax adviser review how you use it, before anyone relies on the output. Provided “as is” under its licence, without warranty.
What it does
The two headline numbers for a let property:
- **Gross yield**: annual rent as a share of the property's value. - **Net yield**: annual rent less the landlord's running costs, as a share of the value.
For example
rental_yield(£12,000.00, £3,000.00, £200,000.00)→ gross basis points 6%, net basis points 4.5%, net income £9,000.00 £12,000 rent on a £200,000 flat with £3,000 costs: 6% gross, 4.5% netrental_yield(£12,000.00, £0.00, £200,000.00)→ gross basis points 6%, net basis points 6%, net income £12,000.00 no costs: net equals grossrental_yield(£10,000.00, £0.00, £300,000.00)→ gross basis points 3.33%, net basis points 3.33%, net income £10,000.00 a third rounds down: £10,000 on £300,000 is 333.33 bp
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
pub fn rental_yield(annual_rent: &Money, annual_costs: &Money, property_value: &Money) -> RentalYield
| annual_rent | Money | rent receivable for a year, zero or more |
| annual_costs | Money | the landlord's annual running costs (agent, insurance, repairs, service charge), zero or more |
| property_value | Money | the price paid or current value, greater than zero |
| returns | RentalYield |
The type it declares, generated into your project
/// Both yields, and the net income behind the net one.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RentalYield {
/// rent / value; 600 = 6.00%
pub gross_basis_points: i64,
/// (rent − costs) / value; negative when costs exceed rent
pub net_basis_points: i64,
/// rent − costs
pub net_income: Money,
}
Your code names it in one line, in the file that uses it
fune!(property.rental-yield@^1); // then call rental_yield(…)
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
use super::funejson::Value; ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
use super::math_round_div::round_div; ← from math.round-div ^1.0.0 · built alongside by fune
use super::money_amount::{money, money_from_value, money_to_value, Money}; ← from money.amount ^1.0.0 · built alongside by fune
// Above this, amount * 10000 is no longer exact as a JavaScript number; the
// same limit applies here so every language refuses the same inputs.
const MAX_MINOR: i64 = 90_000_000_000;
/// Gross and net rental yield in basis points. Each is rounded once, half-up,
/// from the exact ratio, never from a rounded percentage.
///
/// # Panics
/// Panics on mismatched currencies, a value that is not positive, a negative
/// rent or cost, or an amount beyond the exact range.
pub fn rental_yield(annual_rent: &Money, annual_costs: &Money, property_value: &Money) -> RentalYield {
let currency = property_value.currency.as_str();
for other in [annual_rent, annual_costs] {
if other.currency != currency {
panic!("currency mismatch: {} and {}", other.currency, currency);
}
}
if property_value.minor <= 0 {
panic!("propertyValue must be greater than zero, received {}", property_value.minor);
}
if annual_rent.minor < 0 {
panic!("annualRent must not be negative, received {}", annual_rent.minor);
}
if annual_costs.minor < 0 {
panic!("annualCosts must not be negative, received {}", annual_costs.minor);
}
for m in [annual_rent.minor, annual_costs.minor, property_value.minor] {
if m > MAX_MINOR {
panic!("amounts must be at most {} minor units", MAX_MINOR);
}
}
let net = annual_rent.minor - annual_costs.minor;
RentalYield {
gross_basis_points: round_div(annual_rent.minor * 10000, property_value.minor, "half-up"),
net_basis_points: round_div(net * 10000, property_value.minor, "half-up"),
net_income: money(net, currency),
}
}
pub fn rental_yield_to_value(result: &RentalYield) -> Value {
Value::obj(vec![
("grossBasisPoints", Value::Int(result.gross_basis_points)),
("netBasisPoints", Value::Int(result.net_basis_points)),
("netIncome", money_to_value(&result.net_income)),
])
}
pub fn fune_vector(args: &[Value]) -> Value {
rental_yield_to_value(&rental_yield(
&money_from_value(&args[0]),
&money_from_value(&args[1]),
&money_from_value(&args[2]),
))
}Install
fune build
With that line in your source, in a Rust project (language rust in fune.project), fune build resolves it and its 2 dependencies, pins them in fune.lock, downloads only the Rust package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. A crate’s build.rs runs it before every compile. Or pin a range in fune.project and build in one step:
fune add property.rental-yield
The manifest, vectors and README with only the Rust implementation. Install it without the registry with fune add ./property.rental-yield-1.0.1-rust.fune, or fetch it from a terminal with fune pull property.rental-yield@1.0.1:rust.
The whole function, every language, is one file too: property.rental-yield-1.0.1.fune, 15,991 bytes, sha256 3e882f7973bc1f8825bfd157c4753a5bf3177593459909e2f106244e03404142. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
// fune: before property.rental-yield
after — your function gets the result and the arguments, and returns the final result.
// fune: after property.rental-yield
replace — inside this capability’s code only, calls to a dependency go to your function, with the same signature. Other capabilities that use it are unaffected; write in * to replace it everywhere.
// fune: replace math.round-div in property.rental-yield
// fune: replace money.amount in property.rental-yield
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show property.rental-yield --steps.
// fune: step property.rental-yield after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| £12,000 rent on a £200,000 flat with £3,000 costs: 6% gross, 4.5% net | £12,000.00, £3,000.00, £200,000.00 | → | gross basis points 6%, net basis points 4.5%, net income £9,000.00 |
| no costs: net equals gross | £12,000.00, £0.00, £200,000.00 | → | gross basis points 6%, net basis points 6%, net income £12,000.00 |
| a third rounds down: £10,000 on £300,000 is 333.33 bp | £10,000.00, £0.00, £300,000.00 | → | gross basis points 3.33%, net basis points 3.33%, net income £10,000.00 |
| two thirds rounds up: £20,000 on £300,000 is 666.67 bp | £20,000.00, £0.00, £300,000.00 | → | gross basis points 6.67%, net basis points 6.67%, net income £20,000.00 |
| exactly half a basis point rounds up | £0.01, £0.00, £200.00 | → | gross basis points 0.01%, net basis points 0.01%, net income £0.01 |
| costs above rent: negative net yield | £12,000.00, £15,000.00, £200,000.00 | → | gross basis points 6%, net basis points -1.5%, net income -£3,000.00 |
| a negative half basis point rounds away from zero | £0.00, £0.01, £200.00 | → | gross basis points 0%, net basis points -0.01%, net income -£0.01 |
| zero rent | £0.00, £0.00, £200,000.00 | → | gross basis points 0%, net basis points 0%, net income £0.00 |
| rent equal to the value is 100% | £50,000.00, £50,000.00, £50,000.00 | → | gross basis points 100%, net basis points 0%, net income £0.00 |
| high-yield HMO: £38,400 rent, £9,600 costs, £320,000 value | £38,400.00, £9,600.00, £320,000.00 | → | gross basis points 12%, net basis points 9%, net income £28,800.00 |
Show the other 4 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| mixed currencies are refused | €12,000.00, £0.00, £200,000.00 | → | error: currency mismatch |
| a zero value is refused | £12,000.00, £0.00, £0.00 | → | error: propertyValue must be greater than zero |
| a negative rent is refused | -£0.01, £0.00, £200,000.00 | → | error: annualRent must not be negative |
| negative costs are refused | £1.00, -£0.01, £200,000.00 | → | error: annualCosts must not be negative |
More from the author
Both are integer basis points (600 = 6.00%), rounded half-up (a half basis point away from zero), once, from the exact ratio. The net income behind the net yield is returned too, so a caller never recomputes it.
## Edge cases
- Costs above the rent give a negative net yield and a negative net income; that is an answer, not an error. - A zero rent gives a zero gross yield. - All three amounts must be in one currency, and the value must be greater than zero.
## What it does not do
Mortgage interest, tax, voids and capital growth are the caller's to fold into the costs (or not). "Net yield" has no statutory definition; this is the plain (rent − costs) / value that letting agents quote. Rent and value up to £900 million keep the arithmetic exact in every language.
## Before you rely on this
**Not professional advice.** This capability calculates property figures from published rules. It is a software component for developers, not legal or financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have a conveyancer or tax adviser review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.
**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified conveyancer or tax adviser has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.
1.0.1 marks it unreviewed. The code and the tests are unchanged.
Files
| Path | Bytes |
|---|---|
| README.md | 2,130 |
| impl/python.py | 1,647 |
| impl/rust.rs | 2,324 |
| impl/typescript.ts | 1,723 |
| vectors.json | 4,832 |