Skip to main content
CFDLAcademy
All chapters

Part 1 · Thinking in cash flows · Chapter 2 of 28

The object model

Every model you will write in this course — from a one-stream rental to the capstone's financed development deal — is built from the same three ideas. Time is the spine: one dated grid that everything else hangs on. Entities are the cast: the things that earn, owe, own, and pay. Streams are the atoms: dated, directed movements of cash, attached to an entity, laid out on the grid.

When a model is unclear, yours or someone else's, start from the same three questions: what is the grid, who is the cast, which streams touch cash?

Time: one grid, declared once

A model declares exactly one time grid:

time calendar monthly from 2026-01 for 36

This line fixes three decisions for the whole model. The grain — monthly here; daily, quarterly, and annual exist too — is the resolution of every period in the model. The origin, 2026-01, is where period 0 starts. The horizon, for 36, is how many periods exist. Nothing can occur off the grid. A payment before the origin or after the horizon is not clipped or ignored; it is a compile error. The compiler rejects a claim about cash that the grid cannot represent instead of accepting it without a diagnostic.

Choosing the grain is a modeling decision, not a formality, and it is consequential enough that Part III gives it a whole chapter. A general rule: model at the grain at which cash actually moves. Rent moves monthly; model months. A power contract that settles daily needs a daily grid, and an annual grid would average away the variation being modeled.

Phases

Real deals have stages: construction, then lease-up, then operations, then exit. The grid can carry these as phases — named, dated spans:

time calendar monthly from 2026-01 for 36
phase construction from 2026-01 to 2026-09
phase operations from 2026-10 to 2028-12

Phases are useful in two ways. Schedules can reference them (every month while in operations), so when the construction estimate moves by a quarter, you change one date and every schedule that references the phase moves with it. And an expression can read the current phase, so behavior can differ by phase without any stream hard-coding the dates. Copying the dates into a dozen schedules instead reproduces the spreadsheet drift problem.

Entities: the cast

An entity is a named thing that cash flows through. Declaring one takes a family, a name, and — the form you should treat as standard — a type:

entity asset tower : Asset.Real
entity party lender : Party

The family (asset, party, container for a grouping such as a fund, or reference for a market path the model computes — chapter 8) and the name (tower, lender) combine into the reference you use everywhere else: asset.tower, party.lender. The type after the colon (Asset.Real, Party) says what kind of thing this is in a vocabulary the tooling recognizes — real assets, financial assets, intangibles, parties to a transaction. When you later adopt an industry pack, the pack extends this vocabulary with domain types and checks your entities against it — and each pack type states what it specializes (CRE.Asset.RealProperty refines Asset.Real), so "is a" is a recorded fact rather than a naming convention. Refinement carries substance, not just a label: a type inherits every field its master declares, so what you learn about a master holds for everything downstream of it. Contracts have masters too — the language ships abstract ones like Contract.Debt and Contract.Lease that exist only to be refined, never instantiated — and contracts check that they attach to an entity of a type that makes sense. The compiler can reject a lease on a Party only because the model declares what each thing is, not only what it is called.

Entities can also nest — a building that is part of a portfolio, a unit that is part of a building — which gives roll-ups a declared structure to follow. part of is one relation from a small declared vocabulary the ontology carries: a party owns an asset or a fund, a contract is secured_by the asset behind it, a party guarantees a contract or is_counterparty_to one. Today these edges are declarative — validated and published in the results graph, driving no cash themselves — but they are how a model records who holds what, and what stands behind which obligation, as facts rather than as comments. The capstone uses the nesting; for now, it is enough to know that the structure exists.

Make an entity of each participant, not of each input: the building, the operating company, the loan, the counterparty, things that could plausibly have their own statement of cash flows. The rent number is not an entity; it is a claim about an entity, which is the next idea.

Streams: the atoms of cash

A stream is one kind of dated cash movement, attached to an entity:

version 0.1
model "object-model-streams"
time calendar monthly from 2026-01 for 36
phase fitout from 2026-01 to 2026-03
phase operations from 2026-04 to 2028-12

entity asset tower : Asset.Real

// One-time cash out while fitting out the space.
stream tower.fitout_cost on entity asset.tower outflow currency USD {
  schedule on 2026-02
  amount = 250000
}

// Steady rent once operating.
stream tower.rent on entity asset.tower inflow currency USD {
  schedule every month from 2026-04 to 2028-12
  amount = 38000
}

// Operating costs run over the same span.
stream tower.opex on entity asset.tower outflow currency USD {
  schedule every month from 2026-04 to 2028-12
  amount = 11500
}

Every stream has exactly these parts.

The name — tower.rent — is dotted, at least two segments, and unique in the model. The segments are yours to design; use them as a taxonomy (tower.rent, tower.opex, loan.interest) and the results are organized by it, because every series in the output carries the name you chose here.

The attachment — on entity asset.tower — says whose cash this is. Attachment is what makes per-entity statements and roll-ups possible; a stream is never free-floating.

The direction — inflow or outflow — is declared, not inferred from sign. Amounts are written positive; the direction says what they mean. The redundancy is deliberate. When an expression produces cash in the wrong direction, the declared direction lets the tooling detect the contradiction instead of adding the amount to a total without a warning.

The currency names the unit. Explicit per stream, so a model that mixes currencies has to say so where it happens.

The schedule says when — here, the single date on 2026-02 and the recurring every month from … to …. Schedules are a small language of their own (day-of-month rules, month-end, business-day conventions, phase-driven spans) and get a full chapter in Part II.

The amount says how much per occurrence. Here they are constants. In real models they are expressions — reading assumptions, the clock, a price curve, the model's own accumulated state — and most of a model's logic is in those expressions. Also Part II.

One thing a stream is not: a total. tower.rent above is not "rent revenue of 1,254,000" — it is thirty-three dated payments of 38,000. The engine computes the total, but the model stores the dated claims, and everything downstream (discounting, phase analysis, simulation) depends on having them dated.

The trio, assembled

The complete model above contains a time grid with two phases, one entity, and three claims about cash. It is twenty lines long, and a committee could read it aloud. It contains no cell references, no copied formulas, and no computed answer. The NPV of this building is computed only when an engine runs the model, so the arithmetic is done in one place, the engine, and not in your file.

Start a habit now for reading any model. Find the grid, list the entities, then classify every stream as one of the three kinds of claim a stream can be:

  • Scheduled — dates known, amount known. The fitout.
  • Recurring — dates patterned, amount ruled. The rent.
  • Contingent — existence itself depends on something, such as an option exercised or a covenant tripped. You have not met this kind yet.

Part II covers the step from the second kind to the third.

What can go wrong

Trigger these three errors on purpose before moving on. Each one shows a rule the compiler enforces.

A schedule off the grid. Change the rent schedule to end 2029-12 — past the 36-period horizon — and the compiler rejects it: the schedule is out of bounds for the time grid. The fix is a modeling decision: either the horizon is wrong or the claim is.

An undeclared entity. Attach a stream on entity asset.warehouse without declaring a warehouse and the compiler rejects the unresolved reference and names it. Every name used in a model must be declared.

A flat stream name. Name a stream rent — one segment — and the parser rejects it with the rule and an example of the required shape (tower.rent). Dotted names keep the output of a hundred-stream model navigable.

In all three cases the compiler does not adjust the input. It rejects it, names the rule, and leaves the decision to the modeler. A model built this way accumulates no errors that were accepted without a diagnostic.

Exercises

Build the trio yourself, from a nearly blank file — the exercise runs in the page:

Exercise

A studio, from a blank grid

The starter file declares only the time grid. Build the rest.

  1. Declare the studio as an entity.
  2. Add a two-month fitout phase.
  3. Add a monthly rent cost of 1,850 for the full two years.
  4. Add a one-time 12,000 setup cost. Schedule the cost with phase_enter("fitout"), not with a date.

Both streams are outflows, so net cash is negative by construction. The exercise practices the trio behind every model: grid, cast, claims.

Check yourself: total cash out is 12,000 + 1,850 × 24 = 56,400.

Loading exercise…

Then, on your own:

  1. Re-model the studio as your own workspace — real rent, real setup cost. The structure stays the same with your actual numbers; only the claims differ.
  2. Trigger all three errors above, in any order, and read each message before fixing it. The same messages appear throughout the rest of the course.