Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
This post shows how to calculate a carry and roll-down on a yield curve using R. In the fixed income, the carry is a current YTM like a dividend yield in stock. But unlike stocks, even though market conditions remain constant over time, the remaining maturity (life) is bound to decrease due to its maturity date. This makes so called the roll-down yield.

# Carry and Roll-Down on a Yield Curve

Assume that the following yield curve remains constant over time (1 year).

Carry and roll-down are defined under the yield curve unchanged between an investment horizon (3-month or 1-year and so on)  as follows.

 “Carry” is the difference between the yield on a longer-maturity bond and the cost of borrowing (funding cost or risk-free rate or short-term rate). “Roll” offers capital gains when yields dip with the remaining maturity decreasing.

### Carry

If we borrow $1 million at 3% (funding cost) and invest it in a 3-year bond that yields 4% (YTM). After 1 year (investment horizon), we have earned a “carry” of$10,000.

1,000,000 × (4% – 3%) × (360 ÷ 360) = 10,000

Of course, when the investment horizon is a quarter, (360 ÷ 360) is replaced by (90 ÷ 360) in the above equation.

### Roll-Down

In the same example above, if we invest $1 million in 3-year bond priced at par (100) and after a year, this bond will be the 2-year bond which price is priced 102 assuming the yield curve is unchanged, we will have gained$20,000.

(102 – 100) × 10,000 = 20,000

### R code

The R code below implements the above explanations with 1-year investment horizon and annual coupon payments. Coupon bond price is calculated easily by using derivmkts R package.

We assume that we invest a par coupon bond at time t so that coupon bond price at time t+1 is calculated with time t par yield (coupon rate), t-1 maturity, and time t+1 par yield (discounting).

 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 #========================================================## Quantitative ALM, Financial Econometrics & Derivatives # ML/DL using R, Python, Tensorflow by Sang-Heon Lee ## https://kiandlee.blogspot.com#——————————————————–## Carry and Roll-down on the yield curve#========================================================# graphics.off(); rm(list = ls()) library(derivmkts) # bond price function #——————————————————-# Input#——————————————————- fc    <– 0.01    # funding cost v.mat <– 1:10    # maturity # ytmv.ytm <– c(0.022,           0.030,           0.040,           0.046,           0.050,           0.052,           0.053,           0.053,           0.053,           0.054) # placeholder for outputdf <– data.frame(mat=v.mat, ytm = v.ytm, p0 = NA, p1 = NA,                 carry = NA, rolldown = NA, CR = NA) #——————————————————-# sequential calculation#——————————————————-for(t in 1:10) {        # bond price at time t    mat0 <– df$mat[t] ytm0 <– df$ytm[t]        df$p0[t] <– bondpv(ytm0, mat0, ytm0, 1, 1) # bond price at time t+1 if(t==1) { df$p1[t] <– 1 # deterministic            } else {                # maturity reduction at time t+1        mat1 <– df$mat[t–1] ytm1 <– df$ytm[t–1]                # previous coupon(t) and current ytm(t+1)        df$p1[t] <– bondpv(ytm0, mat1, ytm1, 1, 1) } # carry df$carry[t] <– ytm0 – fc         # roll-down    df$rolldown[t] <– (df$p1[t] – df$p0[t])/df$p0[t]        # carry + roll-down    df$CR[t] <– df$carry[t] + df\$rolldown[t]} #——————————————————-# output and graph#——————————————————-print(df) x11(width=16/2, height=9/2);matplot(df[,c(5,6,7)]*100, type=“b”, pch = 16:18, lty = 1,         lwd=3, col=1:3, main = “Carry and Roll-down”,         xlab = “maturity(year)”, ylab = “yield(%)”)legend(“right”, cex=1, col=1:3,        legend=c(“Carry”, “Roll-down”, “Carry + Roll-down”),        pch = c(15), border=“white”, box.lty=0) Colored by Color Scripter cs

Running the above R code delivers the following table for the current bond prices and next ones, carry and roll-down yield components.

Finally, the next figure shows a series of carry, roll-down, and their sum. In an upward sloping yield curve, as maturity gets longer, carry is high but roll-down is low and vice versa when maturity gets shorter. It is not the case but a tendency.

However we can find that the sum of two components is maximized at some medium-term maturity as trade-off between them exists.

### Concluding Remarks

In this post we have understand the basic concept of carry and roll-down and calculate them by hands with R code. These days there are strong expectation of interest rate hikes. This leads to an increasing curvature of a yield curve. Therefore we can analyze this circumstance where carry and roll-down are higher simultaneously at medium-term maturities. $$\blacksquare$$