Deutsch: Forward Raten vom 26.1.2006. Daten aus dem Handelsblatt, die Funktionen behalte ich für mich.
R-Quelltext:
#Zinsdaten aus dem Handelsblatt vom 24.1.2006 ohne 8, 9, 15, 20, 25 und 30 Jahre
# langfristig: swaps (geldkurs)
sc=list(rate=c(2.87,3.05,3.14,3.21,3.27,3.31,3.36,3.50)/100,
maturity=c(1:7,10),
tenors=c(seq(1,1,length=7),3),
date="2006-01-24")
# kurzfristig: libor
lc=list(rate=c(2.385,2.453,2.524,2.653,2.838)/100,
maturity=c(1,2,3,6,12)/12,
date="2006-01-24")
#einige von mir geschriebene Funktionen wandeln in fwd-raten um
lfwd=libor2fwd(lc)
dc=swap2discount(sc)
sfwd=discount2fwd(dc)
fwd<-fwdMerge(lfwd, sfwd)
#schätze parametrisierte Familien (NS und SV)
r =nlm(f=l2norm,p=c(fwd$rate[length(fwd$rate)],fwd$rate[1]-fwd$rate[length(fwd$rate)], 0.12,0.24),y=cbind(fwd$maturity,fwd$rate),steptol=1e-10,iterlim=500, familie="ns")
rs=nlm(f=l2norm,p=c(fwd$rate[length(fwd$rate)],fwd$rate[1]-fwd$rate[length(fwd$rate)],-0.10,0.11,0.1,0.15),y=cbind(fwd$maturity,fwd$rate),steptol=1e-10,iterlim=500, familie="svensson")
png(filename = "Fwdrates_EUR.png", width=1024, height=768, pointsize = 12)
par(bg="lightgrey")
#zeichne Forward Raten (und Familien):
plot(fwd$maturity,fwd$rate,type="p",col=6,lwd=2, main=paste("EUR forwardrate-estimate for ",fwd$date), xlab="time to maturity [in yrs]", ylab="fwd", axes=FALSE)
lines(seq(from=min(fwd$maturity),to=max(fwd$maturity),length=1000),nelsonsiegel(x=seq(from=min(fwd$maturity),to=max(fwd$maturity),length=1000),r$estimate), lty=2 ,col="blue", lwd=2)
lines(seq(from=min(fwd$maturity),to=max(fwd$maturity),length=1000),svensson(x=seq(from=min(fwd$maturity),to=max(fwd$maturity),length=1000),rs$estimate), lty=3, col="green", lwd=3)
legend(x="bottomright",inset=0.01,legend=c("forward rate","Nelson-Siegel","Svensson"),col=c(6,"blue","green"),lwd=2, lty=c(0,2,3), pch=c(1,-1,-1))
yticks=axTicks(2)
axis(side=2,at=yticks,labels=paste(format(100*yticks,digits=3),"%",sep=""))
axis(1)
box()
dev.off()