Simulace dluhopisu ###Yield curve download # Load Quandl package library(Quandl) # Obtain Moody's Baa index data baa <- Quandl("FED/RIMLPBAAR_N_M") baa head(baa) # Identify 9/30/16 yield baa_yield <- subset(baa, baa$Date > "2016-04-30" & baa$Date < "2016-09-30 ") baa_yield <- subset(baa, baa$Date == "2009-07-31") baa_yield class(baa) dim(baa) head(baa) # Convert yield to decimals and view baa_yield <- baa_yield$Value / 100 baa_yield ## # Obtain Moody's Aaa yield aaa <- Quandl("FED/RIMLPAAAR_N_M") aaa head(aaa) # identify yield on September 30, 2016 aaa_yield <- subset(aaa, aaa$Date == "2016-09-30") # Convert yield into decimals aaa_yield <- aaa_yield$Value / 100 aaa_yield class(aaa_yield) plot(aaa, type="l", col="red") b=as.data.frame(aaa_yield) aaa plot(Value ~ Date, aaa, xlab = "Date", ylab="ytm in %", type = "l", col="black") par(new=TRUE) #polygon(aaa$Date,aaa$Value,col="purple", type="l") #axis(1, at = seq(1975L, 2020L, by = 5L)) ### tail(aaa) ######## ########