Skip to content

Performance

Return measurement

Time-weighted, money-weighted and Modified Dietz returns of a portfolio with external cash flows, optionally annualized.

Model id
performance.return_measurement, version 2
Domain
Performance
Evidence
standard
Cost class
instant: A closed-form calculation; a hosted run may take up to 2 seconds.

Formula

rk=VkVk−1+Fk−1−1r_k = \frac{V_k}{V_{k-1} + F_{k-1}} - 1TWR=∏k(1+rk)−1TWR = \prod_k (1 + r_k) - 1V0(1+r)T+∑kFk(1+r)T−tk=VTV_0 (1 + r)^T + \sum_k F_k (1 + r)^{T - t_k} = V_TRMD=V1−V0−∑iFiV0+∑iWiFi,Wi=CD−DiCDR_{\mathrm{MD}} = \frac{V_1 - V_0 - \sum_i F_i}{V_0 + \sum_i W_i F_i}, \quad W_i = \frac{CD - D_i}{CD}Rannual=(1+R)m/k−1R_{\mathrm{annual}} = (1 + R)^{m / k} - 1

Where

rkr_k
The return of sub-period k sub_period_returns
VkV_k
The value at the end of sub-period k values
FkF_k
The external flow at the end of sub-period k; a contribution is positive flows
TWRTWR
Time-weighted return time_weighted_return
V0V_0
The value at the beginning beginning_value
VTV_T
The value at the end ending_value
rr
The money-weighted return per period money_weighted_return
TT
The length of the whole period
tkt_k
The time of flow k flow_times
RMDR_{\mathrm{MD}}
The modified Dietz return modified_dietz_return
V1V_1
The value at the end, in the modified Dietz return ending_value
FiF_i
The i-th external flow flows
WiW_i
The weight of flow i: the share of the period it was invested
CDCD
Calendar days in the period
DiD_i
Days from the start of the period to flow i
RannualR_{\mathrm{annual}}
The return for a year annualized_return
RR
The return over the whole span
mm
Periods in a year periods_per_year
kk
In the annualized return, the periods the return spans; elsewhere, the index of a sub-period periods

Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.

Variables

Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.

Inputs

Time-weighted return, linked geometrically (time_weighted): 5 inputs
Inputs of the calculation time_weighted
NameDescription
CalculationcalculationtextTime-weighted return, linked geometrically
Valuesvaluesmoney (array) · length min 2, max 10081; each [0, 1e+12]Portfolio values V0, V1, ..., Vn, each taken just before that date's external flow
Flowsflowsmoney (array) · length max 10080; each [-1e+12, 1e+12]External flow just after each valuation but the last (one fewer than the values); positive adds money. Omit for none
Periodsperiodsperiods · (0, 100000]Length of the span in periods; by default one per sub-period
Periods per yearperiods_per_yearperiods · (0, 100000]Periods in a year, such as 12, to annualize; omit not to
Money-weighted return, an IRR (money_weighted): 10 inputs
Inputs of the calculation money_weighted
NameDescription
CalculationcalculationtextMoney-weighted return, an IRR
Beginning valuebeginning_valuemoney · [0, 1e+12]Portfolio value at the start
Ending valueending_valuemoney · [0, 1e+12]Portfolio value at the end
Flowsflowsmoney (array) · length max 1000; each [-1e+12, 1e+12]External flows in between; positive adds money
Periodsperiodsperiods · (0, 100000]Periodic flows: the length of the span in periods
Flow timesflow_timesperiods (array) · length max 1000; each [0, 100000]Periodic flows: when each flow occurs, in periods from the start
Start datestart_datedateDated flows: the start
End dateend_datedateDated flows: the end
Flow datesflow_datesdate (array) · length max 1000Dated flows: the date of each flow
Periods per yearperiods_per_yearperiods · (0, 100000]Periods in a year, such as 12, to annualize; omit not to
Modified Dietz return, day-weighted flows (modified_dietz): 9 inputs
Inputs of the calculation modified_dietz
NameDescription
CalculationcalculationtextModified Dietz return, day-weighted flows
Beginning valuebeginning_valuemoney · [0, 1e+12]Portfolio value at the start
Ending valueending_valuemoney · [0, 1e+12]Portfolio value at the end
Start datestart_datedateStart of the period
End dateend_datedateEnd of the period
Flowsflowsmoney (array) · length max 1000; each [-1e+12, 1e+12]External flows; positive adds money
Flow datesflow_datesdate (array) · length max 1000The date of each flow
Periodsperiodsperiods · (0, 100000]Length of the period in periods, for annualizing
Periods per yearperiods_per_yearperiods · (0, 100000]Periods in a year, such as 12, to annualize; omit not to

Outputs

Time-weighted return, linked geometrically (time_weighted): 4 outputs
Outputs of the calculation time_weighted
NameDescription
CalculationcalculationtextTime-weighted return, linked geometrically
Sub period returnssub_period_returnsreturn (array) · length max 10080; each [-1, 100]Return of each sub-period, in order
Time weighted returntime_weighted_returnreturn · [-1, 1e+06]Linked return over the whole span
Annualized returnannualized_returnreturn · [-1, 1e+06]Return compounded to a year; null without periods_per_year
Money-weighted return, an IRR (money_weighted): 5 outputs
Outputs of the calculation money_weighted
NameDescription
CalculationcalculationtextMoney-weighted return, an IRR
Rateraterate · [-0.99, 10]Money-weighted rate per period, or a year for dated flows; null when no rate in [-0.99, 10] solves it
Money weighted returnmoney_weighted_returnreturn · [-1, 1e+06]The rate compounded over the whole span
Annualized returnannualized_returnreturn · [-1, 1e+06]Rate compounded to a year: the rate itself for dated flows; null for periodic flows without periods_per_year
Flow countflow_countcount · [0, 1000]Number of flows
Modified Dietz return, day-weighted flows (modified_dietz): 4 outputs
Outputs of the calculation modified_dietz
NameDescription
CalculationcalculationtextModified Dietz return, day-weighted flows
Modified dietz returnmodified_dietz_returnreturn · [-100, 100]Gain over day-weighted capital
Average capitalaverage_capitalmoney · (0, 1.001e+15]Beginning value plus day-weighted flows: the denominator
Annualized returnannualized_returnreturn · [-1, 1e+06]Return compounded to a year; null without periods_per_year

Calculator

Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.

Loading the calculator…

Worked example

Example quarter_with_a_contribution. Inputs:

{
  "calculation": "time_weighted",
  "flows": [0, 100, 0],
  "periods": null,
  "periods_per_year": 12,
  "values": [1000, 1050, 1180, 1250]
}

Outputs:

{
  "annualized_return": 0.6967032311428643,
  "calculation": "time_weighted",
  "sub_period_returns": [
    0.050000000000000044,
    0.026086956521739202,
    0.05932203389830515
  ],
  "time_weighted_return": 0.14130434782608714
}

Assumptions

  • External flows are positive when money is added and negative when it is withdrawn; values are market values including income.
  • Time-weighted valuations are taken just before each flow; by default every sub-period is one period long, for annualizing.
  • Dated money-weighted flows count years as ACT/365 Fixed, as XIRR does, so their rate is already a year's. A Modified Dietz flow on a given day is held for the rest of the period from that day.

Limitations

  • A sub-period that starts with no money invested, or a Modified Dietz period with no average capital, raises DomainError; so does a return beyond its bounds.
  • The money-weighted rate is null, with a warning, when no rate in [-0.99, 10] solves it; with several, the smallest is reported.
  • Modified Dietz approximates the true time-weighted return; it is exact only when no flows occur. Annualizing a span shorter than a year extrapolates it.

Evidence

Status: standard. Textbook consensus, such as bond duration or the CAPM formula.

Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).

Syllabus

The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.

Citations

  1. Bacon, C. R. (2008). Practical Portfolio Performance Measurement and Attribution, 2nd ed. Wiley. doi:10.1002/9781119206309.ch2 (Chapter 2, pp. 5-37: time-weighted and money-weighted returns, and the day-weighted (Modified) Dietz method). ISBN 9780470059289
  2. Dietz, P. O. (1966). Pension Funds: Measuring Investment Performance. Free Press. https://openlibrary.org/works/OL159516W (The return as gain over average capital invested, flows held for part of the period (LCCN 66012080))
  3. Microsoft. XIRR function (Excel), the dated internal rate of return. https://support.microsoft.com/en-us/office/xirr-function-de1242ec-6477-445b-b11b-a303ad9adc9d (Description and example)

Changelog

  • Version 1: First version.
  • Version 2: Recognize IRR roots at inclusive bracket endpoints (#85).

Use it elsewhere

Documentation
The model's reference page
REST API
GET or POST /v1/models/performance.return_measurement/run
MCP tool
run_model with the model's id, performance.return_measurement. Connect an assistant
Command line
pyeconomics models run performance.return_measurement --help

The worked example, from Python and from the command line:

Python
import pyeconomics

inputs = {
    "calculation": "time_weighted",
    "flows": [0, 100, 0],
    "periods": None,
    "periods_per_year": 12,
    "values": [1000, 1050, 1180, 1250],
}
result = pyeconomics.run("performance.return_measurement", inputs)
print(result.to_json())
Command line
pyeconomics models run performance.return_measurement --inputs - <<'JSON'
{
  "calculation": "time_weighted",
  "flows": [0, 100, 0],
  "periods": null,
  "periods_per_year": 12,
  "values": [1000, 1050, 1180, 1250]
}
JSON