aboutsummaryrefslogtreecommitdiffstats
path: root/clopricer.R
diff options
context:
space:
mode:
Diffstat (limited to 'clopricer.R')
-rw-r--r--clopricer.R87
1 files changed, 0 insertions, 87 deletions
diff --git a/clopricer.R b/clopricer.R
deleted file mode 100644
index d428c2e8..00000000
--- a/clopricer.R
+++ /dev/null
@@ -1,87 +0,0 @@
-rootdir <- "T:/Analytics/CLO/"
-setwd(rootdir)
-options(stringsAsFactors=F)
-
-stripext <- function(name,ext){
- sub(paste(".",ext,sep=""),"",name)
-}
-
-today <- function(){
- as.Date(Sys.time())
-}
-
-listcusips <- function(date, flag=""){
- clodir <- paste(format(date, "%Y%m%d"), flag, sep="")
- cusips <- dir(path=paste(".",clodir,sep="/"), pattern=".report$")
- return(stripext(cusips,"report"))
-}
-
-readcusip <- function(cusip,date,flag=""){
- clodir <- paste(format(date,"%Y%m%d"),flag,sep="")
- temp <- read.table(paste(".",clodir,paste(cusip,"report",sep="."),sep="/"),sep="\t",header=T,fill=T)
- temp <- temp[temp$Scenario!="Scenario",1:25]
- a <-as.matrix(temp$Scenario)
- a <- sub("SCENARIO","",as.character(a))
- temp <- data.frame(a,temp[,2:25])
- tempnames <- colnames(temp)
- colnames(temp) <- c("Scenario",tempnames[2:25])
- return(temp[order(as.numeric(temp$Scenario)),])
-}
-
-readcusip2 <- function(cusip,date){
- clodir <- format(date,"%Y%m%d")
- temp <- read.table(paste(".",clodir,paste(cusip,"report",sep="."),sep="/"),sep="\t",header=T,fill=T)
- temp <- temp[temp$Scenario!="Scenario",1:25]
- a <- t(matrix(unlist(strsplit(as.character(temp$Scenario),"_")),2,nrow(temp)))
- a[,1] <- sub("SCENARIO","",as.character(a[,1]))
- colnames(a) <- c("Scenario","ScenarioType")
- temp <- data.frame(a,temp[,2:25])
- return(temp[order(as.numeric(temp$Scenario)),])
-}
-getcusip <- function(cusip,date,colname,scenariotype){
- cusipdata <- readcusip2(cusip,date)
- as.numeric(cusipdata[cusipdata$ScenarioType==scenariotype,][[colname]])
-}
-
-getcusipinfo <- function(cusip,date,scenariotype,infotype,indextype,indextenor){
- clodir <- paste(format(date,"%Y%m%d"),"Info",sep="/")
- cusipscen <- paste(cusip,scenariotype,sep="_")
- temp <- read.table(paste(".",clodir,paste(cusipscen,infotype,sep="."),sep="/"),sep="\t",header=T,fill=T)
- return(temp[(temp$IndexType==indextype)&(temp$IndexTenor==indextenor),])
-}
-
-A <- c()
-for(cusip in cusipsBB){
- A <- cbind(A,as.numeric(readcusip(cusip,today())$Price))
-}
-colnames(A) <- cusipsBB
-
-pricesAAA <- c()
-for(cusip in cusipsAAA){
- pricesAAA <- rbind(pricesAAA,readcusip(cusip,today())[,c("Price","Duration","Yield","WAL")])
-}
-
-pricesAA <- c()
-for(cusip in cusipsAA){
- pricesAA <- rbind(pricesAA,readcusip(cusip,today())[,c("Price","Duration","Yield","WAL")])
-}
-
-pricesA <- c()
-for(cusip in cusipsA){
- pricesA <- rbind(pricesA,readcusip(cusip,today())[,c("Price","Duration","Yield","WAL")])
-}
-
-pricesBBB <- c()
-for(cusip in cusipsBBB){
- pricesBBB <- rbind(pricesBBB,readcusip(cusip,today())[,c("Price","Duration","Yield","WAL")])
-}
-
-pricesBB <- c()
-for(cusip in cusipsBB){
- pricesBB <- rbind(pricesBB,readcusip(cusip,today())[,c("Price","Duration","Yield","WAL")])
-}
-
-pricesNA <- c()
-for(cusip in cusipsNA){
- pricesNA <- rbind(pricesNA,readcusip(cusip,today())[,c("Price","Duration","Yield","WAL")])
-}