Modified Dietz method: Difference between revisions

Content deleted Content added
FrescoBot (talk | contribs)
m Bot: removing misplaced special no-break space character and minor changes
 
(48 intermediate revisions by 21 users not shown)
Line 1:
{{Short description|Historical performance of an investment portfolio}}
The '''modified Dietz method'''<ref name="Dietz1966">{{cite book
|author=Peter O. Dietz
Line 4 ⟶ 5:
|url=https://books.google.com/books?id=ZUQ_MwEACAAJ
|year=1966
|publisher=Free Press}}</ref><ref>{{Cite journal|last=Dietz|first=Peter|date=May 1968|title=Measurement of Performance of Security Portfolios COMPONENTS OF A MEASUREMENT MODEL: RATE OF RETURN, RISK, AND TIMING|journal=The Journal of Finance|volume=23|issue=2|pages=267–275|doi=10.1111/j.1540-6261.1968.tb00802.x}}</ref><ref name="CIPMCFA2009">{{cite book
|publisher=Free Press}}</ref><ref name="CIPMCFA2009">{{cite book
|author1=Philip Lawton, CIPM
|author2=Todd Jankowski, CFA
Line 13 ⟶ 14:
|isbn=978-0-470-47371-9
|pages=828–
|quote=Peter O. Dietz published his seminal work, Pension Funds: Measuring Investment Performance, in 1966. The Bank Administration Institute (BAI), a U.S.-based organization serving the financial services industry, subsequently formulated rate-of-return calculation guidelines based on Dietz's work.}}</ref> is a measure of the ''ex post'' (i.e. historical) performance of an [[investment portfolio]] in the presence of external flows. (External flows are movements of value such as transfers of cash, securities or other instruments in or out of the portfolio, with no equal simultaneous movement of value in the opposite direction, and which are not income from the investments in the portfolio, such as interest, coupons or dividends.) To calculate the modified Dietz return, divide the gain or loss in value, net of external flows, by the average capital over the period of measurement. The result of the calculation is expressed as a percentage [[rate of return|return]] over the holding period. The average capital weights individual cash flows by the amount of time from when those cash flows occur until the end of the period.
 
To calculate the modified Dietz return, divide the gain or loss in value, net of external flows, by the average capital over the period of measurement. The average capital weights individual cash flows by the length of time between those cash flows until the end of the period. Flows which occur towards the beginning of the period have a higher weight than flows occurring towards the end. The result of the calculation is expressed as a percentage [[rate of return|return]] over the holding period.
This method has the practical advantage over [[internal rate of return]] (IRR) method that it does not require repeated trial and error to get a result.<ref name="Feibel2003">{{cite book
|author=Bruce J. Feibel
|title=Investment Performance Measurement
|url=https://books.google.com/books?id=fzAVZvAGP7cC&pg=PA41
|date=21 April 2003
|publisher=John Wiley & Sons
|isbn=978-0-471-44563-0
|pages=41–
|quote=One of these return calculation methods, the Modified Dietz method, is still the most common way of calculating periodic investment returns.}}</ref>
 
==GIPS==
The cash flows used in the formula are weighted based on the time they occurred in the period. For example, if they occurred in the beginning of the month they would have a higher weight than if they occurred at the end of the month. This is different from the [[simple Dietz method]], in which the cash flows are weighted equally regardless of when they occurred during the measurement period, which works on an assumption that the flows are distributed evenly throughout the period.
This method for return calculation is used in modern portfolio management. It is one of the methodologies of calculating returns recommended by the Investment Performance Council (IPC) as part of their Global Investment Performance Standards (GIPS). The GIPS are intended to provide consistency to the way portfolio returns are calculated internationally.<ref>{{cite web|title=Global Investment Performance Standards (GIPS®) Guidance Statement on Calculation Methodology|url=http://www.gipsstandards.org/standards/guidance/documents/develop/calcmethod.pdf|publisher=IPC|accessdate=13 January 2015}}</ref>
 
With the advance of technology, most systems can calculate a true time-weighted return by calculating a daily return and geometrically linking in order to get a monthly, quarterly, annual or any other period return. However, the modified Dietz method remains useful for performance attribution, because it still has the advantage of allowing modified Dietz returns on assets to be combined with weights in a portfolio, calculated according to average invested capital, and the weighted average gives the modified Dietz return on the portfolio. Time weighted returns do not allow this.
 
This method for return calculation is used in modern portfolio management. It is one of the methodologies of calculating returns recommended by the Investment Performance Council (IPC) as part of their Global Investment Performance Standards (GIPS). The GIPS are intended to provide consistency to the way portfolio returns are calculated internationally.<ref>{{cite web|title=Global Investment Performance Standards (GIPS®) Guidance Statement on Calculation Methodology|url=http://www.gipsstandards.org/standards/guidance/documents/develop/calcmethod.pdf|format=pdf|publisher=IPC|accessdate=13 January 2015}}</ref>
 
==Origin==
The method is named after Peter O. Dietz.<ref>{{cite book
|title=The C.F.A. Digest
Line 38 ⟶ 29:
|publisher=Institute of Chartered Financial Analysts.
|page=72
|quote=A slightly improved version of this method is the day-weighted, or modified Dietz, method. This method adjusts the cash flow by a factor that corresponds to the amount of time between the cash flow and the beginning of the period.}}</ref> The original idea behind the work of Peter Dietz was to find a quicker, less computer-intensive way of calculating an IRR as the iterative approach using the then -quite -slow computers that were available was taking a significant amount of time; the research was produced for BAI, Bank Administration institute.{{Citation needed|date=October 2017}} The modified Dietz method is a linear [[Internal_rate_of_return|IRR]].
 
His approximation was therefore to generate money weighted rates of return for the period. Because there is a GIPS requirement to produce a valuation on a monthly basis at least, using modified Dietz with monthly valuations provides a series of individual monthly money-weighted rates with which can be compounded together to produce a good quality approximation for the longer time period time weighted rate of return
 
==Formula==
Line 71 ⟶ 60:
This assumes that the flow happens at the end of the day. If the flow happens at the beginning of the day, the flow is in the portfolio for an additional day, so use the following formula for calculating the weight:
:<math> W_i = \frac{C -D_i + 1}{C}</math>
 
==Comparison with time-weighted return and internal rate of return==
The modified Dietz method has the practical advantage over the [[true time-weighted rate of return]] method, in that the calculation of a modified Dietz return does not require portfolio valuations at each point in time whenever an external flow occurs. The [[internal rate of return]] method shares this practical advantage with the modified Dietz method.
Conversely, if there exists a portfolio valuation at any point in time, the implied modified Dietz valuation of cashflows at that point in time is quite unlikely to agree with the actual valuation.
 
With the advance of technology, most systems can calculate a time-weighted return by calculating a daily return and geometrically linking in order to get a monthly, quarterly, annual or any other period return. However, the modified Dietz method remains useful for performance attribution, because it still has the advantage of allowing modified Dietz returns on assets to be combined with weights in a portfolio, calculated according to average invested capital, and the weighted average gives the modified Dietz return on the portfolio. Time weighted returns do not allow this.
 
The modified Dietz method also has the practical advantage over [[internal rate of return]] (IRR) method that it does not require repeated trial and error to get a result.<ref name="Feibel2003">{{cite book
|author=Bruce J. Feibel
|title=Investment Performance Measurement
|url=https://books.google.com/books?id=fzAVZvAGP7cC&pg=PA41
|date=21 April 2003
|publisher=John Wiley & Sons
|isbn=978-0-471-44563-0
|pages=41–
|quote=One of these return calculation methods, the Modified Dietz method, is still the most common way of calculating periodic investment returns.}}</ref>
 
The modified Dietz method is based upon a simple rate of interest principle. It approximates the [[internal rate of return]] method, which applies a compounding principle, but if the flows and rates of return are large enough, the results of the Modified Dietz method will significantly diverge from the internal rate of return.
 
The modified Dietz return is the solution <math>R</math> to the equation:
 
:<math>B = A \times (1+R)+ \sum_{i=1}^n F_i \times \left( 1+R \times \frac{T - t_i}{T} \right)</math>
 
where
 
:<math>A</math> is the start value
 
:<math>B</math> is the end value
 
:<math>T</math> is the total length of time period
 
and
 
:<math>t_i</math> is the time between the start of the period and flow <math>i</math>
 
Compare this with the (unannualized) [[internal rate of return]] (IRR). The IRR (or more strictly speaking, an un-annualized holding period return version of the IRR) is a solution <math>R</math> to the equation:
 
:<math>B = A \times (1+R)+ \sum_{i=1}^n F_i \times (1+R)^ \frac{T - t_i}{T}</math>
 
===Example===
Suppose the value of a portfolio is $100 at the beginning of the first year, and $300 at the end of the second year, and there is an inflow of $50 at the end of the first year/beginning of the second year. (Suppose further that neither year is a leap year, so the two years are of equal length.)
 
To calculate the gain or loss over the two-year period,
 
:<math>\text {gain or loss} = B - A - F = 300 - 100 - 50 = $150\text{.}</math>
 
To calculate the average capital over the two-year period,
 
:<math>\text {average capital} = A + \sum \text {weight} \times \text {flow} = 100 + 0.5 \times 50 = $125\text{,}</math>
 
so the modified Dietz return is:
 
:<math>\frac {\text {gain or loss}}{\text {average capital}} = \frac {150}{125} = 120\%</math>
 
The (unannualized) internal rate of return in this example is 125%:
 
:<math>100 \times (1 + 125\%)+ 50 \times (1+125\%)^ \frac{2 - 1}{2} = 225 + 50 \times 150\% = 225 + 75 = 300</math>
 
so in this case, the modified Dietz return is noticeably less than the unannualized IRR. This divergence between the modified Dietz return and the unannualized internal rate of return is due to a significant flow within the period, together with the fact that the returns are large. If there are no flows, there is no difference between the modified Dietz return, the unannualized IRR, or any other method of calculating the holding period return. If the flows are small, or if the returns themselves are small, then the difference between the modified Dietz return and the unannualized internal rate of return is small.
 
The IRR is 50% since:
 
:<math>100 \times (1 + 50\%)^2 + 50 \times (1+50\%)^ 1 = 225 + 50 \times 150\% = 225 + 75 = 300</math>
 
but the unannualized holding period return, using the IRR method, is 125%. Compounding an annual rate of 50% over two periods gives a holding period return of 125%:
 
:<math>(1 + 50\%)^2 - 1 = 2.25 - 1 = 1.25 = 125\%</math>
 
==The simple Dietz method==
The modified Dietz method is different from the [[simple Dietz method]], in which the cash flows are weighted equally regardless of when they occurred during the measurement period. The [[simple Dietz method]] is a special case of the Modified Dietz method, in which external flows are assumed to occur at the midpoint of the period, or equivalently, spread evenly throughout the period, whereas no such assumption is made when using the Modified Dietz method, and the timing of any external flows is taken into account.
Note that in the example above, the flow occurs midway through the overall period, which matches the assumption underlying the simple Dietz method. This means the simple Dietz return and modified Dietz return are the same in this particular example.
 
==Adjustments==
Line 84 ⟶ 144:
and the gain is:
 
:{{nowrap begin}}{{link if exists|end value}} - {{link if exists|start value}} - {{link if exists|net inflow}} = 8,181,000 - 0 - 8,100,000 = 81,000 m {{link if exists| HKD}}{{nowrap end}}
 
so the modified Dietz return is calculated as:
Line 92 ⟶ 152:
So which is the correct return, 1 percent or 366 percent?
 
===Adjusted Timetime Intervalinterval===
The only sensible answer to the example above is that the holding period return is unambiguously 1 percent. This means the start date should be adjusted to the date of the initial external flow. Likewise, if the portfolio is empty at the end of the period, the end date should be adjusted to the final external flow. The end value is effectively the final external flow, not zero.
 
The return annualized using a simple method of multiplying-up 1 percent per day by the number of days in the year will give the answer 366 percent, but the holding period return is still 1 percent.
 
===Example Correctedcorrected===
The example above is corrected if the start date is adjusted to the end of the day on 30 December, and the start value is now 8.1m HKD. There are no external flows thereafter.
 
Line 112 ⟶ 172:
:{{nowrap begin}}{{sfrac|{{link if exists|gain or loss}}|{{link if exists|average capital}}}} = {{sfrac|81,000|8.1m}} = 1 %{{nowrap end}}
 
===Second Exampleexample===
Suppose that a bond is bought for HKD 1,128,728 including accrued interest and commission on trade date 14 November, and sold again three days later on trade date 17 November for HKD 1,125,990 (again, net of accrued interest and commission). Assuming transactions take place at the start of the day, what is the modified Dietz holding-period return in HKD for this bond holding over the year to-date until the end-of-day on 17 November?
 
Line 124 ⟶ 184:
There are no flows, so the gain or loss is:
 
:{{nowrap begin}}{{link if exists|end value}} - {{link if exists|start value}} = 1,125,990 - 1,128,728 = -2−2,738 {{link if exists| HKD}}{{nowrap end}}
 
and the average capital equals the start value, so the modified Dietz return is:
 
:{{nowrap begin}}{{sfrac|{{link if exists|gain or loss}}|{{link if exists|average capital}}}} = {{sfrac|-2−2,738|1,128,728}} = -0−0.24 % 2 d.p.{{nowrap end}}
 
===Contributions - Whenwhen Notnot Toto Adjustadjust the Holdingholding Periodperiod===
This method of restricting the calculation to the actual holding period by applying an adjusted start or end date applies when the return is calculated on an investment in isolation. When the investment belongs inside a portfolio, and the weight of the investment in the portfolio, and the contribution of that return to that of the portfolio as a whole is required, it is necessary to compare like with like, in terms of a common holding period.
 
====Example====
Suppose that at the beginning of the year, a portfolio contains cash, of value $10,000 USD, in an account which bears interest without any charges. At the beginning of the thirdfourth quarter, $8,000 USD of that cash is invested in some US dollar shares (in company X). The investor applies a buy-and-hold strategy, and there are no further transactions for the remainder of the year. At the end of the year, the shares have increased in value by 10% to $8,800 USD, and $100 USD interest is capitalized into the cash account.
 
What is the return on the portfolio and the cash account over the year, and? whatWhat are the contributions from the cash account and the shares? Furthermore, what is the return on the cash account?
 
=====Answer=====
The end value of the portfolio is $2,100 USD in cash, plus shares worth $8,800 USD, which is in total $10,900 USD. There has been a 9 percent increase in value since the beginning of the year. There are no external flows in or out of the portfolio over the year.
 
:{{nowrap begin}}{{link if exists|weighted flows}} = 0{{nowrap end}}
Line 145 ⟶ 205:
so
 
:{{nowrap begin}}{{link if exists|average capital}} = {{link if exists|start value}} = $10,000 {{link if exists| USD}}{{nowrap end}}
 
so the return is:
Line 151 ⟶ 211:
:{{nowrap begin}}{{sfrac|{{link if exists|gain or loss}}|{{link if exists|average capital}}}} = {{sfrac|900|10,000}} = 9 %{{nowrap end}}
 
This 9% portfolio return breaks down between 8 percent contribution from the $800 USD earned on the shares and 1 percent contribution from the $100 USD interest earned on the cash account, but how more generally can we calculate contributions?
 
The first step is to calculate the average capital in each of the cash account and the shares over the full year period. These should sum to the $10,000 USD average capital of the portfolio as a whole. From the average capital of each of the two components of the portfolio, we can calculate weights. The weight of the cash account is the average capital of the cash account, divided by the average capital ($10,000 USD) of the portfolio, and the weight of the shares is the average capital of the shares over the whole year, divided by the average capital of the portfolio.
 
For convenience, we will assume the time weight of the outflow of $8,000 USD cash to pay for the shares is exactly 1/4. This means that the four quarters of the year are treated as having equal length.
 
The average capital of the cash account is:
 
:{{nowrap begin}}{{link if exists|average capital}}{{nowrap end}}
::{{nowrap begin}}= {{link if exists|start value}} - {{link if exists|time weight}} &times; {{link if exists|outflow amount}}{{nowrap end}}
::{{nowrap begin}}= 10,000 - {{sfrac|1|4}} &times; $8,000 {{link if exists| USD}}{{nowrap end}}
::{{nowrap begin}}= 10,000 - $2,000 {{link if exists| USD}}{{nowrap end}}
::{{nowrap begin}}= $8,000 {{link if exists| USD}}{{nowrap end}}
 
The average capital of the shares over the last quarter requires no calculation, because there are no flows after the beginning of the last quarter. It is the $8,000 USD invested in the shares. However, the average capital in the shares over the whole year is something else. The start value of the shares at the beginning of the year was zero, and there was an inflow of $8,000 USD at the beginning of the last quarter, so:
:{{nowrap begin}}{{link if exists|average capital}}{{nowrap end}}
::{{nowrap begin}}= {{link if exists|start value}} - {{link if exists|time weight}} &times; {{link if exists|outflow amount}}{{nowrap end}}
::{{nowrap begin}}= 0 + {{sfrac|1|4}} &times; $8,000 {{link if exists| USD}}{{nowrap end}}
::{{nowrap begin}}= $2,000 {{link if exists| USD}}{{nowrap end}}
 
We can see immediately that the weight of the cash account in the portfolio over the year was:
Line 214 ⟶ 274:
To measure returns net of fees, allow the value of the portfolio to be reduced by the amount of the fees. To calculate returns gross of fees, compensate for them by treating them as an external flow, and exclude accrued fees from valuations.
 
==Annual rate of return==
==Comparison with Time-Weighted Return and Internal Rate of Return==
The modified Dietz method has the practical advantage over the [[true time-weighted rate of return]] method, in that the calculation of a modified Dietz return does not require portfolio valuations at each point in time whenever an external flow occurs. The [[internal rate of return]] method shares this practical advantage with the modified Dietz method.
 
The modified Dietz method has the practical advantage over the [[internal rate of return]] method, in that there is a formula for the modified Dietz return, whereas iterative numerical methods are usually required to estimate the internal rate of return.
 
The modified Dietz method is based upon a simple rate of interest principle. It approximates the [[internal rate of return]] method, which applies a compounding principle, but if the flows and rates of return are large enough, the results of the Modified Dietz method will significantly diverge from the internal rate of return.
 
The modified Dietz return is the solution <math>R</math> to the equation:
 
:<math>B = A \times (1+R)+ \sum_{i=1}^n F_i \times (1+R \times \frac{T - t_i}{T})</math>
 
where
 
:<math>A</math> is the start value
 
:<math>B</math> is the end value
 
:<math>T</math> is the total length of time period
 
and
 
:<math>t_i</math> is the time between the start of the period and flow <math>i</math>
 
Compare this with the (unannualized) [[internal rate of return]] (IRR). The IRR (or more strictly speaking, an un-annualized holding period return version of the IRR) is a solution <math>R</math> to the equation:
 
:<math>B = A \times (1+R)+ \sum_{i=1}^n F_i \times (1+R)^ \frac{T - t_i}{T}</math>
 
For example, suppose the value of a portfolio is 100 USD at the beginning of the first year, and 300 USD at the end of the second year, and there is an inflow of 50 USD at the end of the first year/beginning of the second year. (Suppose further that neither year is a leap year, so the two years are of equal length.)
 
To calculate the gain or loss over the two-year period,
 
:<math>\text {gain or loss} = B - A - F = 300 - 100 - 50 = 150 \text{ USD.}</math>
 
To calculate the average capital over the two-year period,
 
:<math>\text {average capital} = A + \sum \text {weight} \times \text {flow} = 100 + 0.5 \times 50 = 125 \text{ USD,}</math>
 
so the modified Dietz return is:
 
:<math>\frac {\text {gain or loss}}{\text {average capital}} = \frac {150}{125} = 120\%</math>
 
The (unannualized) internal rate of return in this example is 125%:
 
:<math>300 = 100 \times (1 + 125\%)+ 50 \times (1+125\%)^ \frac{2 - 1}{2} = 225 + 50 \times 150\% = 225 + 75</math>
 
so in this case, the modified Dietz return is noticeably less than the unannualized IRR. This divergence between the modified Dietz return and the unannualized internal rate of return is due to a significant flow within the period, and the fact that the returns are large.
 
==Annual Rate of Return==
Note that the Modified Dietz return is a holding-period return, not an annual rate of return, unless the period happens to be one year. Annualisation, which is conversion of the holding-period return to an annual rate of return, is a separate process.
 
==Money-weighted return==
==The Simple Dietz Method==
The modified Dietz method is an example of a money (or dollar) weighted methodology (as opposed to [[time-weighted return|time-weighted]]). In particular, if the modified Dietz return on two portfolios are <math>R_1</math> and <math>R_2</math>, measured over a common matching time interval, then the modified Dietz return on the two portfolios put together over the same time interval is the weighted average of the two returns:
Note also that the [[simple Dietz method]] is a special case of the Modified Dietz method, in which external flows are assumed to occur at the midpoint of the period, or equivalently, spread evenly throughout the period, whereas no such assumption is made when using the Modified Dietz method, and the timing of any external flows is taken into account.
 
==Money-Weighted Return==
The modified Dietz method is an example of a money (or dollar) weighted methodology. In particular, if the modified Dietz return on two portfolios are <math>R_1</math> and <math>R_2</math>, measured over a common matching time interval, then the modified Dietz return on the two portfolios put together over the same time interval is the weighted average of the two returns:
 
:<math>W_1 \times R_1+W_2 \times R_2</math>
Line 276 ⟶ 286:
:<math>W_i = \frac{\text{average capital}_i}{\text{average capital}_1+\text{average capital}_2}</math>
 
==Linked Returnreturn versus Truetrue Timetime-Weightedweighted Returnreturn==
An alternative to the modified Dietz method is to link geometrically the modified Dietz returns for shorter periods. The linked modified Dietz method is classed as a time-weighted method, but it does not produce the same results as the [[time-weighted return|true time weighted]] method, which requires valuations at the time of each cash flow.
 
==Issues==
===Problems with Timingtiming Assumptionsassumptions===
There are sometimes difficulties when calculating or decomposing portfolio returns, if all transactions are treated as occurring at a single time of day, such as the end of the day or beginning of the day. Whatever method is applied to calculate returns, an assumption that all transactions take place simultaneously at a single point in time each day can lead to errors.
 
For example, consider a scenario where a portfolio is empty at the start of a day, so that the start value A is zero. There is then an external inflow during athat day of F = $100. By the close of the day, market prices have moved, and the end value is $99.
 
If all transactions are treated as occurring at the end of the day, then there is zero start value A, and zero value for average capital, because the day-weight on the inflow is zero, so no modified Dietz return can be calculated.
Line 291 ⟶ 301:
There are sometimes other difficulties when decomposing portfolio returns, if all transactions are treated as occurring at a single point during the day.
 
For example, consider a fund opening with just $100 of a single stock that is sold for $110 during the day. During the same day, another stock is purchased for $110, closing with a value of $120. The returns on each stock are 10% and 120/110 - 1 = 9.0909% (4 d.p.) and the portfolio return is 20%. The asset weights ''w<sub>i</sub>'' (as opposed to the time weights ''W<sub>i</sub>'') required to get the returns for these two assets to roll up to the portfolio return are 1200% for the first stock and a negative 1100% for the second:
 
:w*10/100 + (1-w)*10/110 = 20/100 → w = 12.
 
Such weights are absurd, because the second stock is not held short.
Line 299 ⟶ 309:
The problem only arises because the day is treated as a single, discrete time interval.
 
===Negative or Zerozero Averageaverage Capitalcapital===
In normal circumstances, average capital is positive. When an intra-period outflow is large and early enough, average capital can be negative or zero. Negative average capital causes the Modified Dietz return to be negative when there is a profit, and positive when there is a loss. This resembles the behaviour of a liability or short position, even if the investment is not actually a liability or a short position. In cases where the average capital is zero, no Modified Dietz return can be calculated. If the average capital is close to zero, the Modified Dietz return will be large (large and positive, or large and negative).
 
One partial workaround solution involves as a first step, to capture the exception, detecting for example when the start value (or first inflow) is positive, and the average capital is negative. Then in this case, use the simple return method, adjusting the end value for outflows. This is equivalent to the sum of constituent contributions, where the contributions are based on simple returns and weights depending on start values.
Line 313 ⟶ 323:
:At the end of Day 40, the remaining 20 shares are worth 12.50 dollars per share
 
The gain or loss is end value - start value + outflow:
 
:<math>20 \times 12.50 - 100 \times 10 + 80 \times 15</math>
::<math>= 250 - 1,000 + 1,200</math>
::<math>= 50450</math>
 
There is a gain, and the position is long, so we would intuitively expect a positive return.
Line 329 ⟶ 339:
::<math>= -50 \text { dollars}</math>
 
The Modifiedmodified Dietz return in this case goes awry, because the average capital is negative, even though this is a long position. The Modified Dietz return in this case is:
 
:<math>\frac {\text {gain or loss}}{\text {average capital}} = \frac {50450}{-50} = -100900 \%</math>
 
Instead, we notice that the start value is positive, but the average capital is negative. Furthermore, there is no short sale. In other words, at all times, the number of shares held is positive.
 
We then measure the simple return from the shares sold:
Line 345 ⟶ 355:
and combine these returns with the weights of these two portions of the shares within the starting position, which are:
 
:<math>\frac {80}{100} = 80 \%</math> and <math>\frac {20}{100} = 20 \%</math> respectively.
 
This gives the contributions to the overall return, which are:
Line 368 ⟶ 378:
 
====Limitations====
This workaround has limitations. It is possible only if the holdings can be split up like this.
 
It is not ideal, for two further reasons, which are that it does not cover all cases, and it is inconsistent with the Modified Dietz method. Combined with Modified Dietz contributions for other assets, the sum of constituent contributions will fail to add up to the overall return.
Line 378 ⟶ 388:
==Visual Basic==
 
<sourcesyntaxhighlight lang="vbvbnet">
Function georet_MD(myDates, myReturns, FlowMap, scaler)
' This function calculates the modified Dietz return of a time series
Line 439 ⟶ 449:
 
End Function
</syntaxhighlight>
</source>
 
==Java Methodmethod for Modifiedmodified Dietz Returnreturn==
<sourcesyntaxhighlight lang="java">
private static double modifiedDietz (double emv, double bmv, double cashFlow[], int numCD, int numD[]) {
 
/* emv: Ending Market Value
Line 455 ⟶ 465:
 
try {
 
double[] weight = new double[cashFlow.length];
 
if (numCD <= 0) {
throw new ArithmeticException ("numCD <= 0");
}
 
for (int i = 0; i < cashFlow.length; i++) {
if (numD[i] < 0) {
throw new ArithmeticException ("numD[i]<0 , " + "i=" + i);
}
weight[i] = (double) (numCD - numD[i]) / numCD;
Line 470 ⟶ 479:
 
double ttwcf = 0; // total time weighted cash flows
for (int i = 0; i < cashFlow.length; i++) {
ttwcf += weight[i] * cashFlow[i];
}
 
double tncf = 0; // total net cash flows
for (int i = 0; i < cashFlow.length; i++) {
tncf += cashFlow[i];
}
Line 493 ⟶ 502:
return md;
}
</syntaxhighlight>
</source>
 
== Excel VBA function for modified Dietz return ==
<syntaxhighlight lang="VBVBnet">
Public Function MDIETZ(dStartValue As Double, dEndValue As Double, iPeriod As Integer, rCash As Range, rDays As Range) As Double