Money-Weighted Return
Calculate the money-weighted return of every position and of the whole portfolio: the annual rate at which the money put in grew into the money taken out plus the value still held (the internal rate of return, or XIRR, of the transactions).
Unlike the time-weighted return, it depends on when money was added: buying more just before a rally raises it and buying at a peak lowers it. It therefore measures the investor’s own result, including the timing of every purchase and sale, rather than the result of the assets alone.
The cash flows are every purchase (money in, including costs), every sale (money out, after costs), every cash dividend received (money out, on its ex-dividend date) and the latest value of the positions still held, on the last date of the historical data.
For more information, see the following book:
- Bacon, C.R. (2008). “Practical Portfolio Performance Measurement and Attribution.” Wiley, 2nd edition, chapter 2.
Also known as: internal rate of return, IRR, XIRR, dollar-weighted return.
Money-Weighted Return in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_money_weighted_return as shown below.
from financetoolkit import Portfolio
portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")
portfolio.get_money_weighted_return()
Which returns:
| Invested | Received | Dividends | Latest Value | First Transaction | Money-Weighted Return | |
|---|---|---|---|---|---|---|
| ASML | 6348.35 | 736.149 | 8610.47 | 202762 | 2000-01-07 | 0.2123 |
| SKY | 3339.23 | 261.99 | 901.062 | 9943.92 | 2000-01-10 | 0.0652 |
| AMZN | 5042.91 | 192.851 | 0 | 28768 | 2000-01-28 | 0.2054 |
| FIX | 1976.93 | 18.43 | 1294.06 | 141625 | 2000-02-23 | 0.2513 |
| MSFT | 5529.99 | 147.7 | 3367.52 | 55073.6 | 2000-02-28 | 0.1359 |
| AMD | 2384.36 | 1431.84 | 0 | 40309.6 | 2000-04-27 | 0.1462 |
| AAPL | 5750.96 | 266.963 | 1246.48 | 47639 | 2000-05-08 | 0.2784 |
| FICO | 4917.94 | 576.42 | 102.122 | 94576 | 2000-06-01 | 0.1659 |
| BAC | 2401.58 | 303.8 | 888.08 | 4044.8 | 2000-11-16 | 0.0672 |
| ALGN | 9918 | 324.77 | 0 | 12515.3 | 2001-09-18 | 0.0334 |
| CWST | 1373.89 | 91.95 | 0 | 6149.43 | 2001-10-15 | 0.1339 |
| OXY | 1994.56 | 424.898 | 876.077 | 1732.59 | 2001-11-16 | 0.0404 |
| WMT | 2261.02 | 163.39 | 965.758 | 11029.9 | 2001-12-28 | 0.1285 |
| CAMT | 546.73 | 104.06 | 67.87 | 5088.72 | 2002-08-07 | 0.2856 |
| NVDA | 201.303 | 29.941 | 49.646 | 14556.2 | 2002-09-20 | 0.3245 |
| NFLX | 1662.85 | 207.478 | 0 | 7506.9 | 2002-11-18 | 0.207 |
| GOOGL | 4668.1 | 359.26 | 304.08 | 46750.7 | 2004-08-24 | 0.2196 |
| MPWR | 30633 | 446.4 | 3301.39 | 132254 | 2005-09-16 | 0.2745 |
| BLDR | 1682.82 | 121.254 | 0 | 2728.8 | 2006-12-22 | 0.1004 |
| VSS | 10364.5 | 995.66 | 3122.51 | 14636.3 | 2009-06-05 | 0.0765 |
| AVGO | 1568.81 | 134.64 | 6096.41 | 21230.9 | 2009-11-02 | 0.5773 |
| MCHI | 2965.43 | 139.96 | 336.097 | 2646 | 2011-04-26 | 0.0093 |
| VOO | 20238.2 | 368.76 | 3863.3 | 53790.7 | 2011-12-20 | 0.1506 |
| META | 4813.61 | 0 | 81.125 | 9639.3 | 2012-06-20 | 0.1931 |
| KHC | 722.41 | 242.21 | 108.25 | 223.2 | 2017-03-07 | -0.0525 |
| EMXC | 1403.3 | 477.33 | 148.616 | 1467.36 | 2019-05-03 | 0.0893 |
| Portfolio | 134711 | 8568.1 | 35730.9 | 968688 | 2000-01-07 | 0.1763 |
Parameters
get_money_weighted_return accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Portfolio’s rounding. | 2 |