Skip to main content
CFDLAcademy
All chapters

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

Why a language?

Every financial model is a claim: if these assumptions hold, this is the cash. An acquisition model claims what a business generates under a set of growth and margin assumptions. A development model claims what a building earns after construction, lease-up, and exit. The model is the set of claims; the spreadsheet, the code, and the deck are ways of writing them down.

This course teaches you to write those claims in CFDL, the Cash Flow Domain Language. Before the syntax, it is worth being precise about why a language — rather than a grid of cells — is the right way to write them.

What a spreadsheet actually stores

A spreadsheet stores answers. Each cell holds a formula that produces one number for one period. The model's logic exists only as the pattern those formulas make, and you infer that pattern by clicking through cells one at a time.

That design has consequences that every practitioner has met:

  • The logic is invisible. "Rent escalates 3% annually on the anniversary" is nowhere in the workbook. What exists is =D14*1.03 in one cell, copied across a row, and the reader must reverse-engineer the intent from the arithmetic. Reviewing a model means auditing cells, and an audit finds errors only in the cells it examines.
  • Copies drift. The row is the unit of reuse, and rows are copied. When the copy in column AB was fixed and the one in AJ was not, both appear correct until a result depends on the cell where they differ.
  • There is no meaningful diff. Two versions of a workbook differ in thousands of cells. A reviewer cannot tell which of them are the decision (the changed assumption) and which are recalculation, so review depends on trust.
  • Uncertainty is bolted on. The workbook produces one path. Scenario tabs and add-ins add distributions to a workbook built for a single answer, and those additions are the first parts to break.

These problems are not a failure of skill. They follow from storing the claims as their consequences.

Declaring instead of computing

A CFDL model states the claims themselves and lets an engine derive the consequences. Here is a complete model — small, but complete: an engine can run it and produce a cash-flow series, totals, and NPV:

version 0.1
model "first-claim"
time calendar monthly from 2026-01 for 24

entity asset workshop : Asset.Real

// The claim: the workshop rents for 4,200 a month, every month, for two years.
stream workshop.rent on entity asset.workshop inflow currency USD {
  schedule every month from 2026-01 to 2027-12
  amount = 4200
}

// And it costs 900 a month to keep the lights on.
stream workshop.operating_cost on entity asset.workshop outflow currency USD {
  schedule every month from 2026-01 to 2027-12
  amount = 900
}

Read it top to bottom. Time is declared once, for the whole model: a monthly grid, starting January 2026, 24 periods long. The thing that earns the cash is declared as an entity. Each claim about cash is a stream: a direction (money in or money out), a currency, a schedule saying when it occurs, and an amount saying how much. No line in this file is a computed answer. Every line is an assumption you could read aloud to a committee, in the order you would state it.

This approach (store the claims, derive the numbers) is the basis of the rest of the course, and it has four specific benefits.

The model is reviewable. A colleague reviews the statement amount = 4200, not seven hundred copies of a formula. When the rent assumption changes, the diff between versions is one line, and it is the line a reviewer should look at. Version control works on models the way it works on contracts: the diff shows what changed.

The model is checkable before it runs. Because the claims are explicit, a compiler can check them. It rejects a stream scheduled beyond the end of the time grid, a reference to an entity that was never declared, or a contract missing a required term. Each error names the file, the line, and the fix. A spreadsheet rejects nothing; it computes whatever the cells contain. This course triggers compiler errors deliberately, because reading them is a large part of learning the language.

The same model gives you the number and the distribution. Uncertainty is part of the language, not an add-in. Later in the course you will replace a fixed assumption with a distribution and re-run the same file to get percentiles instead of a point estimate, with the same claims and the same engine.

The run is reproducible. The same model and the same inputs produce the same results, to the byte, on any machine — including simulated ones, because random draws come from a declared seed. When a committee asks where a number came from, reproducibility means the answer can be regenerated and checked.

What happens when you run a model

You will run models constantly, so it is worth knowing what the toolchain does with one. The pipeline has two halves.

The compiler reads your source files and checks everything it can check without running: syntax, references, schedules against the time grid, and contract terms against their pack's requirements. It then emits an intermediate representation (IR) — a complete, self-contained description of the model, with every name resolved and every schedule made explicit. The IR is a plain, inspectable JSON document: the model with nothing left implicit.

The engine takes the IR and a run configuration — the discount rate, the as-of date, scenario overrides, simulation settings. From those it produces results: the cash of every stream in every period, aggregates, metrics like NPV and IRR, and enough tracing to answer where any number came from. Chapter 3 is about reading these.

Two things about this split matter to you as an author. First, everything the compiler can catch is caught before any number is produced — a model that compiles has already passed every structural check the language defines. Second, the run configuration is kept outside the model, which is why one model can serve base case, downside, and simulation without being edited. Keeping "what is claimed" separate from "how it is run" is a discipline the language enforces for you.

A deliberately narrow language

CFDL is deliberately narrow. It describes dated cash flows and the structures that generate them — it is not a general programming language, and what it excludes matters as much as what it includes.

The compiler rejects any construct the language does not define: no syntax parses and then has no effect. The language excludes hidden state: an amount expression can read the model's declared assumptions, the clock, entity fields, contract terms, the opening balance of an account, and the model's own published series, and nothing else. An expression cannot read a file, the network, or the wall-clock time, so two runs cannot differ. An ambiguous schedule or a missing term is an error; the compiler never applies a default without a diagnostic.

For a modeler, these restrictions are the purpose of the design. Every behavior of the model traces to a line someone wrote, which means every number in the output traces to a claim someone made. Making that trace legible is most of financial modeling discipline, and CFDL builds that discipline into the language.

How this course works

The course is five parts. Part I (you are here) builds the mental model: objects, time, and how to read results. Part II teaches the core language, construct by construct, on models that stand alone without any industry pack. Part III is judgment — choosing the grain of a model, choosing between constructs, and the finance semantics the language encodes. Part IV is the capstone: one commercial real-estate development deal carried end to end, from skeleton to equity waterfall, growing chapter by chapter the way a real deal model does. Part V is reference.

Chapters marked deep dive cover the internals — the compiler's stages, the evaluation order, the diagnostic system. They are written for readers who want them; the core track never depends on them.

One habit to start now: run everything. Paste any complete model in this course into the playground at cfdl.dev/playground and run it against the real engine. Most code blocks also carry an "open in playground" button that does this in one click. The models are checked against the engine before a chapter ships, so if the text and the engine disagree, the engine result is correct and the text has an error; please report it.

Exercises

The first exercise runs right here in the page, against the real engine — edit, press Run, and compare with the solution when you have an answer of your own.

Exercise

A rent increase, as claims

The workshop's landlord raises the rent 5% for the second year.

  1. Split the single rent stream into two streams.
  2. Set year one to 4,200 a month.
  3. Set year two to the expression 4200 * 1.05, not a pre-computed number. The model must show the base and the increase, the way you would state the terms aloud.

Before you run, compute the expected change: the lifetime rent total rises by 4,200 × 0.05 × 12 = 2,520 over the starter's.

Loading exercise…

Then two more, on your own:

  1. Break the model on purpose: schedule the rent through 2028-12, past the end of the 24-period grid, and read the error you get. Note that it names the schedule, not just a line number — the compiler reports errors in the model's own vocabulary.
  2. From your own work, pick one spreadsheet formula you have had to explain to someone. Write down, in a sentence, the claim it implements. That sentence is what you will be writing directly, starting in the next chapter.