knitr::opts_chunk$set(echo = FALSE, message=FALSE, warning = FALSE) library(LendingClub) suppressPackageStartupMessages(library(dplyr)) library(knitr) suppressMessages(library(ggplot2)) LC_CRED<- lc_MakeCredential(params$investorID, params$APIkey) holdings<- LendingClub::lc_DetailedNotesOwned()$content summarydata<- lc_AccountSummary()$content atRisk<- { at_risk_status<- c("Late (16-30 days)", "Late (31-120 days)", "Charged Off") x<- holdings[holdings$loanStatus %in% at_risk_status,] sum(as.numeric(x$noteAmount)- as.numeric(x$principalReceived)) }
stats<- c("Account Total", "Available Cash", "Interest Received", "Principal at Risk", "Interest-Risk (IR) Ratio") vals<- as.numeric(c(summarydata$accountTotal, summarydata$availableCash, summarydata$receivedInterest, atRisk, round(as.numeric(summarydata$receivedInterest)/atRisk,2))) summtable<- data.frame(stats, vals) kable(summtable, col.names= NULL, align = c("l","r"), format.args = list(big.mark = ','), padding = 2)
x<-lapply(split(holdings, f= holdings$portfolioName), summary) x<- c(x, list( summary (holdings))) names(x)[length(x)]<- "Total" for (i in 1:length(x)){ names(x[[i]])[2] <- names(x[i]) } y<- Reduce(function(...) merge(..., by= 'col_labs', all.x=TRUE), x) y<- y[c(1,4,3,8,6,5,7,9,2), ] colnames(y)[1]<- "" kable(y, row.names= FALSE, format.args = list(big.mark = ','), padding = 2)
h<- ggplot(holdings %>% group_by(grade) %>% summarize(counts =n())) h<- h + aes(x= strtrim(grade, 1), y= counts) h<- h + geom_bar(stat='identity') h<- h + theme_classic() h<- h + labs(x= "Grade", y= "Loan Count") h
dat<-holdings %>% mutate(CFRatio= round((as.numeric(paymentsReceived) - as.numeric(noteAmount)) /as.numeric(noteAmount)*100,2)+100 +1, orderDate= as.Date(orderDate)) dat$simpleStatus <- case_when(dat$loanStatus == "Charged Off" ~ "Complete", dat$loanStatus == "Current" ~"Performing", dat$loanStatus == "Fully Paid" ~ "Complete", dat$loanStatus == "In Grace Period" ~ "Performing", dat$loanStatus == "In Review" ~ "Performing", dat$loanStatus == "Issued" ~ "Performing", dat$loanStatus == "Late (16-30 days)" ~ "Late", dat$loanStatus == "Late (31-120 days)" ~ "Late") ThreeYear<- as.Date(Sys.time())-(365*3) FiveYear<- as.Date(Sys.time()-(365*5)) g<- ggplot(dat) g<- g + aes(x= as.Date(Sys.time())-orderDate, y= CFRatio, group= portfolioName, color= simpleStatus) g<- g + geom_point() # g<- g + scale_x_date(limits= c(ThreeYear-150, as.Date(Sys.time())+50)) g<- g + scale_x_continuous() g<- g + facet_wrap(~portfolioName, ncol=2) g<- g + theme_classic() g<- g + labs(x= "Age in Days", y= "Payback Ratio") g<- g + geom_hline(yintercept = 100, linetype="dashed") g<- g + theme(legend.position="none", panel.border = element_rect(colour = "black", fill=NA)) g
At Risk Ratio is the Principal at Risk as a percentage of the note amount. This is a measure of portfolio health indicating how much of the invesmet is at risk for defaulting or has already done so.
Interest-Risk (IR) Ratio is the ratio of interest payments received to the principal at risk in the portfolio
Wgt Int Rate interest rate weighted by the outstanding principal.
Payback Ratio measures the difference between cash invested in a note and the total payments received. The payments include both interest and principal. All notes start at zero and will increase as payments are made. A note with a ratio greater than 100 indicates that more cash was received than was initially invested. Notes will start at the bottom left of the chart and trend towards the upper right corner as they mature.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.