### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Messages - gaoc


1
##### Foliofn - LC / Best Tool for FOLIO Selling
« on: December 07, 2016, 12:00:00 AM »
Pricing is tricky. It involves lots of things, e.g. your goal, market price, note quality, risk, timing. The best tool usually is a custom strategy according to your personal preference.
2
##### Foliofn - LC / stale incorrect data in notes-ext.csv file
« on: December 07, 2016, 12:00:00 AM »
Even the web page is not up to date. When a payment is just made, the payment history is updated but remaining payments is not updated. It takes a few days for remaining payments to catch up. Screen scraping is not a bad idea if you don't sell it too frequently.
3
##### Foliofn - LC / calculate the right YTM with R
« on: November 22, 2016, 12:00:00 AM »
Some posts are complaining about the YTM provided by foliofn. I found that the YTM is usually wrong when a note is less than 1 year or has a discount rate. If your strategy is to find a decent YTM with bigger discount rate and less remaining payments, their YTM is meaningless and you have to calculate by yourself. I would like to share my algorithm. Any feedback and comments are welcome.

The basic idea is to resolve r, monthly interest rate, from this formula:

a=p*(r*(1+r)^n/((1+r)^n-1))

Where a is monthly payment, p is askPrice (assume that you buy it with askPrice) and n is the remaining payments. p and n are provided in the CSV file.
a is not provided so we have to calculate it. We still use the same formula, but for this time p is outstanding principal and r is the original monthly interest rate . Monthly interest rate is not directly provided, but you get it by dividing annual interest rate by 12. Some people would argue that r is a geometrical mean instead of a arithmetic mean. Well, I had the same point until I found that it is more common to use arithmetic mean. If we want to take into account the monthly 1% service fee, adjust a by multiplying it with 0.99.  Once we get a, we can start resolving the equation with a single unknown variable r. It is a nonlinear equation and there is no analytical solution for r. So we have to use numerical method to get an approximation of r.  There are many ways to do numerical calculation. The easiest way is probably Newton method.

finally YTM=12*r*100%

Here is the R code to calculate Yield. You have to add the column of MonthlyPayment to the original dataframe before you pass it to this function.

getYield <- function(a,tol=1E-12,x0=1,N=20) {
m<-as.numeric(a["MonthlyPayment"])
n<-as.numeric(a["Remaining.Payments"])

h <- 0.001
i <- 1; x1 <- x0
p <- numeric(N)
while (i<=N) {
df.dx <- (f(x0+h,m,pr,n)-f(x0,m,pr,n))/h
x1 <- (x0 - (f(x0,m,pr,n)/df.dx))
p <- x1
i <- i + 1
if (abs(x1-x0) < tol) break
x0 <- x1
}

return(p[i-1]*12*100)
}

f<-function(r,a,p, n)
{
y<-a-p*(r*(1+r)^n/((1+r)^n-1))
return(y)
}

A real example
https://www.lendingclub.com/foliofn/browseNotesLoanPerf.action?showfoliofn=true&loan_id=31317108&order_id=130405930&note_id=60503781

Interest rate 15.61%
Outstanding Principal   \$9.66
Remaining Payments 12

r=0.1561/12= 0.01300833

a=p*(r*(1+r)^n/((1+r)^n-1))=9.66*(0.01300833*(1+0.01300833)^12/((1+0.01300833)^12-1))=0.8746782, which matches the monthly payment provided by Foliofn

finally, let's resolve the equation with Newton's Method

0.8746782 = 9.34*(r*(1+r)^12/((1+r)^12-1))

r= 0.018425

YTM=r*12*100%=22.1%