Sub topic 5
Time-weighted return when cash moves in and out
This chapter assumes you know how to compute a period return and compound returns, and that you have read the earlier chapters on benchmarks and on cumulative and active return. The Python examples use only the standard library.
The problem: cash flows distort simple returns
The formula end value / start value - 1 works only when nobody adds or removes money. Suppose a portfolio grows from 1,000 to 2,100 after a 1,000 deposit. The account gained 100, and the manager did not earn the other 1,000. If you ignore the deposit, you report +110%. If you ignore the timing, you may mis-credit a gain or loss to the manager.
A benchmark index has no deposits or withdrawals. To compare a portfolio with it fairly, you need a return that measures only the investment decisions inside the portfolio. That return is the time-weighted return (TWR). It removes the effect of the size and timing of external cash flows.
What counts as a cash flow
An external cash flow is money that crosses the portfolio boundary: a deposit, a withdrawal, or securities transferred in or out. These flows must be neutralised.
These items are not external flows. They are part of performance:
- Dividends and interest paid into the portfolio and kept there.
- Trades, including reinvestment of income.
- Trading costs and fund expense ratios.
- Management fees charged to the account. Net-of-fee returns include them, and gross-of-fee returns add them back. State which one you report.
A dividend paid out to a bank account outside the portfolio is a withdrawal. Treat it as an external flow, or you will understate returns.
The method: split, measure, link
TWR has three steps:
- Value the portfolio immediately before every external cash flow.
- Split the full period into sub-periods at each flow date. Within one sub-period there are no flows, so the simple return formula is valid.
- Link the sub-period returns by compounding:
TWR = (1 + r1) × (1 + r2) × ... × (1 + rn) − 1
This is geometric linking. You multiply growth factors rather than adding percentages, because each sub-period starts from the value the previous one produced.
Worked example
You start with 1,000. The portfolio rises to 1,100, so sub-period 1 returned +10%. You then deposit 1,000, giving a new starting value of 2,100. The portfolio falls to 1,890, so sub-period 2 returned −10%.
# Each tuple is (value at start of sub-period, value at end before the next cash flow).
# A 1000 deposit is made after the first sub-period.
subperiods = [(1000.0, 1100.0), (2100.0, 1890.0)]
growth = 1.0
for start, end in subperiods:
growth *= end / start
twr = growth - 1
print(round(twr, 4)) # -0.01: +10% then -10% links to about -1%
# Money actually put in: 2000. Value at the end: 1890.
print(1890.0 - 2000.0) # -110.0 loss in currency termsThe TWR is about −1%, and the investor lost 110 in currency terms. Both numbers are correct, and they answer different questions.
- TWR asks how the investments performed, whatever the investor did with cash. This is the number to compare with a benchmark.
- The currency loss asks what happened to the investor's own money. The deposit landed just before a 10% drop, so most of the investor's money was exposed to the loss.
Adding the percentages gives +10% − 10% = 0%. That is wrong, because the −10% applied to a larger base. Always compound.
Choosing a flow-timing convention
TWR needs an assumption about when in a period a flow arrives. You must apply the same rule to every period.
| Convention | Base for the period return | Typical use |
|---|---|---|
| Flow at start of period | Previous end value plus the flow | Deposits invested at the open |
| Flow at end of period | Previous end value, flow added afterwards | Contributions credited at the close |
| Valued on the flow date | Exact valuation just before the flow | Daily-valued accounts, the preferred method |
The convention changes the answer whenever the market moves on the flow day. For a flow of 1,000 into a 1,100 portfolio, the base is 2,100 under the first rule and 1,100 under the second.
A reusable function
This function takes the end value of each period, the external flow at the start of each period, and the opening value. It also annualises the result and computes an active return against a benchmark.
def twr(end_values, start_flows, start_value):
"""Link period returns. The flow is added at the start of its period."""
growth = 1.0
previous = start_value
for end, flow in zip(end_values, start_flows):
base = previous + flow
if base <= 0:
raise ValueError("Period base value must be positive")
growth *= end / base
previous = end
return growth - 1
def annualize(total_return, days):
return (1 + total_return) ** (365 / days) - 1
def link(period_returns):
growth = 1.0
for r in period_returns:
growth *= 1 + r
return growth - 1
# Period 1: no flow, 1000 -> 1100. Period 2: deposit 1000, 2100 -> 1890.
portfolio = twr([1100.0, 1890.0], [0.0, 1000.0], 1000.0)
benchmark = link([0.08, -0.07]) # the index has no cash flows
print(round(portfolio, 4)) # -0.01
print(round(benchmark, 4)) # 0.0044
print(round(portfolio - benchmark, 4)) # -0.0144 active return over the period
print(round(annualize(portfolio, 60), 4)) # annualised only if the period is 60 daysThe benchmark return comes from linking the index's own period returns. The portfolio TWR lags it by about 1.4 percentage points over the same dates.
Edge cases
Valuation on flow dates. True TWR needs a portfolio valuation at every external flow. If your custodian values the account only monthly, you cannot compute exact sub-period returns. A common approximation is the Modified Dietz method. It estimates each period's return as the gain divided by the start value plus the time-weighted flows. You then link the monthly Modified Dietz returns, which is accurate when flows are small and the market does not move sharply.
Large flows. A flow that is large relative to the portfolio makes the Modified Dietz error bigger. Value the portfolio on the flow date and split the period there. Many institutional policies require this once a flow exceeds about 10% of the portfolio.
Near-zero or negative bases. If the start value plus the flow is zero or negative, the sub-period return is undefined. This happens when an account is nearly emptied and then refilled. Start a new return series at that point, and say so in the report.
Return of exactly −100%. If a sub-period ends at zero, the growth factor is 0, and the whole linked TWR becomes −100%. Later recovery cannot change it, because one factor of zero multiplies everything.
Many sub-periods. Daily valuation gives about 250 sub-periods a year. Linking is still just a product. Compute it with a running multiplication, as above, or sum log returns and exponentiate. Both give the same answer within floating-point error.
Order of linking. Multiplication is commutative, so sub-period order does not change the linked result. The order does matter for drawdown, which a later chapter covers.
Comparing with the benchmark
Use the same dates, the same currency and the same return basis (total return) for the portfolio TWR and the benchmark. Then compute active return as the portfolio TWR minus the benchmark return. The arithmetic difference is easy to read. The geometric ratio (1 + portfolio) / (1 + benchmark) − 1 is more accurate for compounding over several years. Say which one you use, and use it consistently.
Common mistakes
- Adding sub-period returns instead of compounding them.
- Using a start value that does not include the deposit when the deposit arrives at the start of the period.
- Treating a reinvested dividend as an external deposit, which double counts it.
- Treating a fee as an external flow, which hides its cost from the return.
- Comparing a TWR that includes flows with a benchmark measured over different dates.
- Reporting an annualised TWR for a period shorter than a year.
Exercise
A portfolio starts at 2,000. In month 1 it returns +5%. At the end of month 1 you deposit 2,000. In month 2 the portfolio returns −5%. Calculate the time-weighted return over the two months, and the gain or loss in currency terms.
Show answer
Month 1 ends at 2,000 × 1.05 = 2,100. After the deposit, month 2 starts at 4,100 and ends at 4,100 × 0.95 = 3,895. TWR = 1.05 × 0.95 − 1 = −0.0025, or −0.25%. You put in 2,000 + 2,000 = 4,000 and ended with 3,895, so the currency result is −105. The percentage loss is small, but the deposit exposed more money to the decline.
Exercise
A portfolio has a TWR of +6.0% over a year. Its benchmark returned +7.5% over the same dates. Compute the arithmetic active return and the geometric active return to two decimal places.
Show answer
Arithmetic: 6.0% − 7.5% = −1.50 percentage points. Geometric: 1.06 / 1.075 − 1 = −0.013953, or −1.40%. The two figures differ because the geometric version divides by the benchmark growth factor.