{"id":"cashflow-mirr","version":"1.0.0","description":"MIRR of periodic cash flows from a finance rate and a reinvestment rate, with compounded and discounted totals.","supported_operations":["modified internal rate of return","MIRR with finance rate and reinvestment rate","Excel MIRR function equivalent","MIRR calculator for a project","internal rate of return with a reinvestment assumption","future value of positive flows over present value of negative flows","return when cash is reinvested at a different rate","MIRR of cash flows with several sign changes"],"unsupported_operations":["ordinary IRR by root finding (use cashflow-irr)","dated cash flows (use cashflow-xirr)","a single rate used for both finance and reinvestment by default","NPV or payback of the flows (use cashflow-npv or cashflow-payback-period)"],"semantics":["Inputs: cash_flows (array of 2 to 2000 decimal strings in time order, first flow at time 0, one period apart; positive is money received, negative is money paid), finance_rate (the periodic rate paid on negative flows, decimal greater than -1 and at most 100), reinvest_rate (the periodic rate earned on reinvested positive flows, same range), scale (0 to 12, default 2, for fv_positive and pv_negative), rate_scale (0 to 12, default 10, for mirr) and rounding (default half-up). Both rates are required: there is no default and they are never assumed equal.","With n the number of flows and k = 0 .. n-1 the index of a flow: fv_positive = sum over the positive flows of cash_flow_k * (1+reinvest_rate)^(n-1-k), that is the positive flows compounded forward to the LAST period (index n-1); pv_negative = sum over the negative flows of cash_flow_k / (1+finance_rate)^k, that is the negative flows discounted back to time 0 (a value at most 0). Zero flows contribute nothing.","MIRR = (fv_positive / (-pv_negative))^(1/(n-1)) - 1. The exponent uses n-1 (the number of periods between the first and the last flow), not n. This is Excel MIRR and equals (NPV(reinvest, positives) * (1+reinvest)^n / (NPV(finance, negatives) * (1+finance)))^(1/(n-1)) - 1 with Excel's t1 NPV.","If there is no positive flow or no negative flow the result is not_computable (details.reason needs_both_signs). If fv_positive or the magnitude of pv_negative reaches 1e20, or the MIRR magnitude reaches 1e20, the result is not_computable (details.reason overflow).","Exact path: every sum is computed in exact decimal arithmetic with an absolute error below 1e-33 and the quantities fv_positive, pv_negative and mirr are each first rounded half-even to 30 fractional digits, so a result that is mathematically an exact decimal (for example a MIRR of exactly 0.1) is recovered exactly and is not disturbed by directed rounding; they are then rounded once to scale or rate_scale with the rounding mode. The MIRR ratio itself is formed from the unsnapped sums (relative accuracy about 1e-80, however small or large the sums are, so a rate near -1 over thousands of periods still gives its finite MIRR). mirr is greater than -1.","More than 2000 cash flows, or a decimal string longer than 64 UTF-8 bytes, is limit_exceeded, checked before parsing. Percent values are not accepted: 0.08 means 8 percent per period.","Every rounded output is rounded exactly once from the unrounded value using the rounding mode: half-up (ties away from zero, the default), half-even, half-down (ties toward zero), up (away from zero), down (toward zero), ceiling, floor. Amount outputs print exactly scale fractional digits and rate-like outputs exactly rate_scale fractional digits; a result that rounds to zero prints without a minus sign (never '-0.00').","Decimal string fields (amounts, rates) must match ^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$ with at most 20 integer digits and at most 20 fractional digits; a JSON number, exponent form, leading plus, surrounding spaces, percent sign, missing integer part or trailing dot is invalid_input. Rates are decimal fractions (0.065 means 6.5 percent; \"6.5\" means 650 percent). A decimal string longer than 64 UTF-8 bytes is limit_exceeded, checked before parsing.","Disclaimer: arithmetic calculation only; not financial, tax, legal, or investment advice."],"limits":{"max_items":2000,"max_string_bytes":64},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["cash_flows","finance_rate","reinvest_rate"],"properties":{"cash_flows":{"type":"array","minItems":2,"maxItems":2000,"items":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","maxLength":64}},"finance_rate":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","maxLength":64},"reinvest_rate":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","maxLength":64},"scale":{"type":"integer","minimum":0,"maximum":12},"rate_scale":{"type":"integer","minimum":0,"maximum":12},"rounding":{"type":"string","enum":["half-up","half-even","half-down","up","down","ceiling","floor"]}}},"output_schema":{"type":"object","additionalProperties":false,"required":["mirr","fv_positive","pv_negative"],"properties":{"mirr":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","maxLength":64},"fv_positive":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","maxLength":64},"pv_negative":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","maxLength":64}}},"examples":[{"input":{"cash_flows":["-120000","39000","30000","21000","37000","46000"],"finance_rate":"0.10","reinvest_rate":"0.12","rate_scale":4},"output":{"mirr":"0.1261","fv_positive":"217297.50","pv_negative":"-120000.00"}},{"input":{"cash_flows":["100","200","-50","300","-200"],"finance_rate":"0.05","reinvest_rate":"0.06","rate_scale":12},"output":{"mirr":"0.342823387842","fv_positive":"682.45","pv_negative":"-209.89"}}],"execute_url":"/v1/tools/cashflow-mirr/versions/1.0.0/execute"}