irr

PortfolioDCF.irr()

Nominal internal rate of return (money-weighted return, MWRR) of the portfolio cash flow over the full historical period, honoring the configured cash flow strategy.

The cash-flow vector (investor perspective) on a monthly grid t = 0 .. N, where N = portfolio.ror.shape[0], is:

  • t = 0 (one month before first_date): -initial_investment

  • t = 1 .. N: -cash_flow_ts (withdrawals become inflows, contributions outflows)

  • t = N (last_date): additionally + the terminal wealth index value (liquidation; floored at 0, so the terminal withdrawal happens only if there is a positive balance left)

The annualized effective IRR is returned. With no intermediate cash flows the result equals Portfolio.get_cagr for the full period.

IRR is a rate, so there is no future/present-value variant: discounting the flows would yield the real rate (the get_cagr(real=True) axis), not “the IRR in PV”.

Returns:
float

Annualized effective IRR. NaN if the cash flow has no sign change (no real root, e.g. pure accumulation with a zero terminal value). With contributions and withdrawals interleaved the equation may have several real roots; the root nearest the solver’s seed is returned.

Examples

>>> pf = ok.Portfolio(["SPY.US", "AGG.US"], ccy="USD", last_date="2024-10")
>>> ind = ok.IndexationStrategy(pf)
>>> ind.initial_investment = 10_000
>>> ind.frequency = "year"
>>> ind.amount = -1_000
>>> pf.dcf.cashflow_parameters = ind
>>> pf.dcf.irr()