Discount cashflows
Set an annual discount rate when running a model:
import { cashflow, currencies, defineModel, entity, inflow, periods, run, schedule } from "deccf";
const asset = entity.asset();
const rent = cashflow({ owner: asset, direction: inflow, schedule: schedule.annual(), amount: 10_000 });
const model = defineModel({
name: "discounted-rent",
currency: currencies.SEK,
timeline: periods.annual({ from: "2026-01", count: 10 }),
entities: { asset },
flows: { rent },
});
const result = run(model, { discountRate: 0.08 });
console.log(result.metrics.npv);
return model;The equivalent run-config field is deterministic.annual_discount_rate. Set only one of them. The rate must be a finite number greater than −100%. If omitted, NPV uses a zero rate.
NPV and IRR use each occurrence's placement (start, mid, or end). The model calendar defines the time scale: 365 periods per year for daily, 52 weekly, 12 monthly, 4 quarterly, and 1 annual.
result.metrics exposes npv, irr, and wal aliases; versioned values are also available under result.deterministic.metrics. IRR or WAL may be null if the cashflows do not allow a solution.