liveBook · Manning

Dollar-weighted return

As explained in Build a Robo-Advisor with Python (From Scratch)

A dollar-weighted return is an investment return that accounts for the timing and amount of external cash flows, commonly through an internal-rate-of-return calculation.

A dollar-weighted return measures investment performance while accounting for the timing and amount of deposits and withdrawals. It is useful when the investor’s cash-flow decisions affect the result. section 7.0 section 7.1

A two-deposit investment

Suppose an investor deposits 10, deposits another 10 one year later, and liquidates the position for 19.8 after two years. The dollar-weighted return solves 0 = 10 + 10/(1+r) − 19.8/(1+r)^2, producing an IRR of about −0.66%. The negative result reflects that the weaker return occurred after the account became larger. section 7.1 section 7.1.2

The calculation is analogous to an internal-rate-of-return calculation: find the single rate that makes the net present value of dated cash flows equal zero. Deposits and withdrawals receive their actual signs, while the final liquidation value uses the opposite sign from deposits. section 7.1.2

Listing 7.2 General solution for the dollar-weighted return
from datetime import datetime

cashflows = [10, 10, -19.8]
dates = ['2020-01-01', '2021-01-01', '2022-01-01']
dates = [datetime.strptime(dt, '%Y-%m-%d') for dt in dates]   #1

def f(x, *args):
    cashflows, dates = args
    sumPVs = 0
    for i in range(len(cashflows)):
        Y = (dates[i] - dates[0]).days/365   #2
        sumPVs += cashflows[i]/(1+x)**Y
    return sumPVs
root = fsolve(f, 0, args=(cashflows, dates))   #3
print('The Dollar-Weighted Return is ', root.item())

Generalizes the calculation with arbitrary cash flows and dates, converts YYYY-mm-dd strings to dates, discounts using elapsed days over 365, and solves with SciPy’s fsolve. section 7.1.2

Use the result with the choice of performance question in mind:

  • Compare it with a time-weighted return when deposits and withdrawals make the two measures diverge. section 7.3
  • Treat it as a measure of the investor’s dollar experience, especially when the timing of investment decisions matters. section 7.3

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Derives the IRR equation and implements a generalized dated-cash-flow solver, but does not develop alternative numerical methods.
Examples
Uses two deposits totaling 20, a final value of 19.8, an IRR equation, and generalized Python cash-flow inputs.
What it assumes
Assumes familiarity with cash flows, discounting, and net present value while building from a concrete investment example.
What you can do after
Apply it via SciPy’s fsolve to compute an IRR from dated cash flows.
How it connects
Contrasts with time-weighted return and connects directly to internal rate of return and net present value.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.