[R-SIG-Finance] LIBOR Yield Curve.
Matt Considine
matt at considine.net
Sat Dec 19 16:16:46 CET 2015
On 12/19/2015 6:00 AM, r-sig-finance-request at r-project.org wrote:
> LIBOR Yield Curve.
Here is a markdown file I use to print out a list of recent LIBOR
rates. The URL and code might be of help. I recognize too that it may
not be the most elegant/efficient, but it has worked for my ad hoc purposes
Matt
---
title: "LIBOR"
output: pdf_document
---
```{r echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
library(Quandl)
library(quantmod)
library(XML)
library(lubridate)
library(xtable)
currentDate <- Sys.Date()
eopm <- currentDate - days(day(currentDate))
sopm <- currentDate - days(day(currentDate))
sopm <- sopm - days(day(sopm) - 1)
##for just latest date
##eopm <- currentDate
##sopm <- currentDate - days(day(currentDate))
LIBOR <- getSymbols(src="FRED",Symbols=c("USD1MTD156N","USD3MTD156N"))
all_webpage <-
'http://www.global-rates.com/interest-rates/libor/american-dollar/american-dollar.aspx'
all_web.table = readHTMLTable(all_webpage, header=T, which=14,
stringsAsFactors=F)
all_data <- gsub("[^a-zA-Z0-9\\.\\ -]","",as.matrix(all_web.table[,]))
colnames(all_data) <- c("data",colnames(all_data[,2:ncol(all_data)]))
all_dates <- as.Date(colnames(all_data[,2:ncol(all_data)]), "%m-%d-%Y")
datarows <- c(match("USD LIBOR - 1 month",all_data[,1]),match("USD LIBOR
- 3 months",all_data[,1]))
newdata <- as.xts(t(all_data[datarows,2:ncol(all_data)]),
order.by=all_dates)
colnames(newdata) <- LIBOR
storage.mode(newdata)<-"numeric"
LIBORdata <- cbind(USD1MTD156N,USD3MTD156N)
newdata2 <- rbind(LIBORdata,newdata)
newdata2 <- newdata2[!duplicated(index(newdata2))]
colnames(newdata2) <- c("1mo LIBOR","3mo LIBOR")
datablock <- newdata2[paste(sopm,"::",eopm,sep=''),]
newdatablock <- as.matrix(datablock)[NROW(datablock):1,,drop=FALSE]
print(xtable(newdatablock,digits=5),floating=TRUE,comment=FALSE,type="latex")
```
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the R-SIG-Finance
mailing list