Analyze a raw cash flow vector
cashflow_analyze_flowsCompute NPV, IRR, and payback directly from a list of period cash flows. Use this when you have existing cash flow numbers and need to evaluate returns without contract modeling.
Instructions
Compute NPV, IRR and payback directly on a list of period cash flows, with no contract model involved.
Use this when the numbers already exist, for example flows lifted from a spreadsheet, a schedule produced elsewhere, or a quick sanity check.
The first element sits at period 0 and is not discounted. Outflows are negative.
Args:
flows (array of numbers): Cash flow per period, flows[0] at t=0. Needs at least 2 entries.
period ('monthly' | 'annual'): What one element represents. Default 'monthly'. Determines how the rate is annualized.
discount_rate_annual (number): Effective annual rate for NPV, e.g. 0.14 for 14%. Default 0.
interpolate_payback (boolean): Return a fractional payback period instead of whole periods. Default false.
Returns: npv, irrAnnual, irrPeriodic, irrAvailable, irrUnavailableReason, payback and cumulative totals.
irrAnnual is null when the vector has no reportable IRR: no outflow, no inflow, or flows that never sum positive. The reason says which.
A vector whose sign changes more than once may have several real IRRs. The engine returns one and flags nothing, which is a property of IRR itself. signChanges is reported so you can tell when to trust NPV instead.
Examples:
Use when: "What is the IRR of -1000, 500, 500, 500?"
Use when: "Discount these annual flows at 12% and tell me the NPV."
Don't use when: you have contract terms rather than flows (use cashflow_evaluate_contract)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flows | Yes | Cash flow per period. flows[0] is period 0 and is not discounted. | |
| period | No | What one element represents. | monthly |
| interpolate_payback | No | Return a fractional payback period instead of whole periods. | |
| discount_rate_annual | No | Effective annual discount rate, e.g. 0.14 for 14%. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| npv | Yes | ||
| payback | Yes | ||
| netTotal | Yes | ||
| irrAnnual | Yes | ||
| irrPeriodic | Yes | ||
| signChanges | Yes | ||
| irrAvailable | Yes | ||
| totalInflows | Yes | ||
| totalOutflows | Yes | ||
| discountRatePeriodic | Yes | ||
| irrUnavailableReason | Yes |