inst/examples/graph_payoff.R

# SERVE VETTORIZZARE, SISTEMARE CON UNA FUNZIONE DELLA LIBRERIA


tmp2<-Vectorize(FUN = callSPread)
tmp2<-function(x){Vectorize(FUN = callSPread)(s=x,1,1.2)}


tmp<-function(x)tmp2(s=x,1)
windows()
curve(tmp2,from=.5,to=1.7,lwd=2,col='red'); grid()


tmp2<-function(x){Vectorize(FUN = call)(s=x,1)}
curve(tmp2,from=.5,to=1.7,lwd=2,col='red'); grid()

windows()
x<-seq(-5,5,by=0.1)
opt<-barrOption(last(s)< -2, put(strike=0)(last(x)), reb=1)
plot(x,sapply(x,opt),lwd=4,type='l',col='lightblue'); grid(lwd=2)

y<-array(NA,length(x))
for(i in 1:length(x)){
    y[i]<-opt(x[i])
}
lampoverde/Der documentation built on Jan. 8, 2018, 12:01 p.m.