Code covered by the BSD License  

Highlights from
Fitting Survival Probability Models

image thumbnail

Fitting Survival Probability Models



Companion code for "Fitting Survival Probability Models" article.

function protLeg = protectLeg(Term,Settle,PL_Date,Basis,LIBOR,Recovery,probfun,b)
%protectLeg Computes the market value of protection leg

PL_Time = yearfrac(Settle,PL_Date,Basis);
PLQ = probfun(PL_Time,b);

PLDF = LIBOR.getDiscountFactors(PL_Date);

protLeg = zeros(size(Term));
for spreadidx=1:length(Term)
    PLtmpidx = PL_Time < Term(spreadidx);
    PLDFtmp = PLDF(PLtmpidx);
    PLQtmp = PLQ(PLtmpidx);
    protLeg(spreadidx) = (1 - Recovery)*sum(-PLDFtmp.*diff([1 PLQtmp]'));

Contact us