DECCF · Cash Flow Modeler and Calculator

Errors, ordering, and limits

Errors

Validation and calculation throw ModelError with a stable code; path, period, and details may be present depending on where the error occurred. Callback errors are usually wrapped with the declaration name and period. Example codes include:

  • DECCF_INVALID_MODEL, DECCF_INVALID_TIMELINE, DECCF_INVALID_DATE
  • DECCF_UNDECLARED_REFERENCE, DECCF_DUPLICATE_DECLARATION
  • DECCF_FLOW_ORDER for missing or not-yet-calculated dependencies
  • DECCF_INPUT_DOMAIN, DECCF_INPUT_SHAPE, DECCF_INVALID_RUN
  • DECCF_CURRENCY_MISMATCH, DECCF_INVALID_DISCOUNT_RATE
  • DECCF_INVALID_BOOKING, DECCF_INVALID_BOOKING_AMOUNT, DECCF_UNBALANCED_BOOKING
  • DECCF_INVALID_TRIGGER, DECCF_AMBIGUOUS_TRIGGER, DECCF_UNDECLARED_TRIGGER
  • DECCF_SCHEDULE_FINER_THAN_TIMELINE, DECCF_PHASE_OVERLAP

Use code for machine handling. The message is intended for diagnosis.

Calculation order

Compilation verifies references, entity parents, agreement subjects, owners, schedules, action targets, and the flow dependency graph. Cycles in flow order are rejected. Per period, fields, lifecycles, and agreements are updated before events. Cashflows then run in dependency order, followed by options and period-end calculations.

Same-period reads of a cashflow require dependsOn. ctx.sum() cannot read future periods. JavaScript callbacks run synchronously.

Run scope

Run options accept inline deterministic.inputs. runScenarios() uses an input-reference Map for each scenario; curve overrides use the { series: { points, interpolation } } form. It returns one result per scenario and accepts Monte Carlo run settings for scenario batches.

The public dates, series, and built-in metrics cover count periods. Projection periods are evaluated, and custom metrics use the last calculated date.

Type declaration and runtime differences

  • lifecycle.onEnter is declared as Action[] in TypeScript, but runtime expects { state, actions } entries. Runtime also reads actions on a transition, though that field is absent from the declaration.
  • actions.setField accepts money and input references when created, but runtime ultimately requires a finite number; a Money object is rejected.
  • Distribution options expose clip in the options type. Runtime reads clip from the distribution's parameter object, so place it there.

See the API overview and calculation context for the current interfaces.

Currency and numbers

Cashflows with an explicit currency must match the model reporting currency. Option payoffs enter model totals and NPV using their numeric amounts, so use the model currency for consistent valuation.

Calculations use JavaScript Number. Money values carry a currency reference; money(), scaleMoney(), and convertMoney() provide amount construction, scaling, and explicit rate-based conversion.