The Macauley duration is defined for fixed rate bonds as
The sum is over all bond cash flows, including the coupons and the principal at maturity.
Each cash flow occurs at tᵢ and has a present value denoted by PVᵢ.
V is the sum of all PVᵢ and equals of course the present value of the bond.
Although this formula could be in principle applied on any type of financial instrument as long as its present value V is not 0, nobody does so in practice.
The reason is that this formula returns a value in time units - for example 8.5 years for a 10-year bond - that turns out to be very close to the sensitivity of the bond price wrt interest rates, but only if the instrument is a fixed rate bond.
It is easy to prove that for a fixed rate bond and a continuously compounded discounting rate y, the Macaulay duration equals the Modified duration defined by
This equality reduces to an approximation when the rate y is not continuously compounded or when the cash flows are not those of a fixed rate bond.
It makes no sense to use the Macaulay duration for swaps!
Most people today use the Modified duration to represent in annual units the interest rate risk of certain financial instruments because this definition of duration can also apply to instruments that pay floating rate coupons.
A par floater for example would have a Modified duration exactly equal to zero, if the first coupon rate has not yet been fixed. Otherwise its duration would equal that for the first coupon.
Some people have the impression they can calculate the Modified duration of a swap by considering the swap as a portfolio of two bonds: A long fixed rate bond and a short floater.
Then the argument goes, the swap duration could be defined as the sum of the two durations.
There is no basis to this argument for the simple reason that the Modified duration is not additive!
You can see this by considering a portfolio of two equal zero bonds, each maturing in 10 years. If the Modified duration were additive, the portfolio's duration would equal 10 + 10 = 20 years, which is absurd!
The correct definition of the Modified duration D of a portfolio is:
D = w₁D₁ + w₂D₂ + ... + wₙDₙ
where Dᵢ is the Modified duration of the iᵗʰ bond and wᵢ is the iᵗʰ bond's weight defined as:
wᵢ = market value of iᵗʰ bond / market value of portfolio
This definition makes sense only for portfolios of long bonds. It makes no sense for portfolios of mixed long and short positions.
As a proof, consider a receiver swap seen as an equivalent portfolio consisting of a long bond with a 10 year duration and a short floater with zero duration. Assume also that both bonds have an equal absolute market value.
Then the total market value becomes zero and the weights w₁ and w₂ jump to infinity!
In fact, the final result for the Modified duration also jumps to infinity, as it should because the concept of Modified duration is a "relative" concept: It expresses the interest rate risk of an instrument relative to its current market value.
This is also the intuition behind why the Modified duration cannot be applied to a swap.
Because a swap's relative interest rate risk is - at least at inception - infinite!
What does make sense for single swaps or portfolio of swaps is the concept of "dollar duration", which is defined as the usual swap's flat DV01.
A portfolio manager should thus calculate the "dollar duration" of the whole portfolio by adding the DV01s of the booked trades. If the portfolio is funded externally, i.e. if the funding instruments are not part of the portfolio as is, for example, the case with pure bond portfolios, it would then make sense to divide the thus computed "dollar duration" with the market value of the portfolio to arrive to a "relative" duration metrics that may be interpreted as Modified duration of the whole portfolio.