Functional Weave
Code in Python

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% net
  • rental_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 gross
  • rental_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.

def rental_yield(annual_rent: Money, annual_costs: Money, property_value: Money) -> RentalYield
annual_rentMoneyrent receivable for a year, zero or more
annual_costsMoneythe landlord's annual running costs (agent, insurance, repairs, service charge), zero or more
property_valueMoneythe price paid or current value, greater than zero
returnsRentalYield

The type it declares, generated into your project

@dataclass(frozen=True)
class RentalYield:
    """Both yields, and the net income behind the net one."""

    #: rent / value; 600 = 6.00%
    gross_basis_points: int
    #: (rent − costs) / value; negative when costs exceed rent
    net_basis_points: int
    #: rent − costs
    net_income: Money

Your code names it in one line, in the file that uses it

from fune.property.rental_yield import rental_yield  # property.rental-yield@^1
impl/python.py · 31 lines · open · raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from .math_round_div import round_div  ← from math.round-div ^1.0.0 · built alongside by fune
from .money_amount import Money, money  ← from money.amount ^1.0.0 · built alongside by fune
from .property_rental_yield_types import RentalYield

# Above this, amount * 10000 is no longer exact as a JavaScript number; the
# same limit applies here so every language refuses the same inputs.
_MAX_MINOR = 90_000_000_000


def rental_yield(annual_rent: Money, annual_costs: Money, property_value: Money) -> RentalYield:
    """Gross and net rental yield in basis points. Each is rounded once,
    half-up, from the exact ratio, never from a rounded percentage."""
    currency = property_value.currency
    for other in (annual_rent, annual_costs):
        if other.currency != currency:
            raise ValueError("currency mismatch: %s and %s" % (other.currency, currency))
    if property_value.minor <= 0:
        raise ValueError("propertyValue must be greater than zero, received %r" % (property_value.minor,))
    if annual_rent.minor < 0:
        raise ValueError("annualRent must not be negative, received %r" % (annual_rent.minor,))
    if annual_costs.minor < 0:
        raise ValueError("annualCosts must not be negative, received %r" % (annual_costs.minor,))
    for m in (annual_rent.minor, annual_costs.minor, property_value.minor):
        if m > _MAX_MINOR:
            raise ValueError("amounts must be at most %d minor units" % (_MAX_MINOR,))
    net = annual_rent.minor - annual_costs.minor
    return 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),
    )

Install

fune build

With that line in your source, in a Python project (language python in fune.project), fune build resolves it and its 2 dependencies, pins them in fune.lock, downloads only the Python 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. Or pin a range in fune.project and build in one step:

fune add property.rental-yield
Download for Python property.rental-yield-1.0.1-python.fune · 11,789 bytes sha256 ae09523e2bd5bd7dd722412dcf6a948db5d4c5804c28649714f10cdd931b7953

The manifest, vectors and README with only the Python implementation. Install it without the registry with fune add ./property.rental-yield-1.0.1-python.fune, or fetch it from a terminal with fune pull property.rental-yield@1.0.1:python.

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.

CaseArgumentsExpected
£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
CaseArgumentsExpected
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

PathBytes
README.md2,130
impl/python.py1,647
impl/rust.rs2,324
impl/typescript.ts1,723
vectors.json4,832