search for: hestoncallvec

Displaying 2 results from an estimated 2 matches for "hestoncallvec".

2011 Aug 26
3
How to vectorize a function to handle two vectors
...(phi, k, t) { integrand <- function(u){Re(exp(-1i*u*k)*phi(u - 1i/2, t)/(u^2 + 1/4))}; res <- 1 - exp(k/2)/pi*integrate(integrand,lower=0,upper=Inf)$value; return(res); } subHeston <- c(0.6067,-0.7571,0.2928,0.0707,0.0654); kV <- c(0.9,1,1.2,1.3) tV <- c(0.1,0.4,0.5, 1) HestonCallVec <- function(phi, kVec, t) { sapply(kVec, function(k){Price_call(phi, k, t)}) } HestonCallVec(phiHeston(subHeston), kV, 1) subHeston <- c(0.6067,-0.7571,0.2928,0.0707,0.0654); kV <- c(0.9,1,1.2,1.3) tV <- c(0.1,0.4,0.5, 1) HestonCallVec2 <- function(phi, kVec, tVec) { sapply(tVec, f...
2011 Aug 18
3
Error message: object of type 'closure' is not subsettable
...g*exp(-(d*t)))/(1 - g)) ) return(exp(C*theta + D*v0)) } } ## Calculating the Heston model price with fourier HestonCall<-function(k,t) { res<-Price_callVec(phiHeston(kappa, rho, eta, theta, v0),k,t) return(res) } ##### Vectorizing the function to handle vectors of strikes and maturities HestonCallVec <- function(k,t) { mapply (HestonCall, k, t) } lb <- c(0, -0.9, 0, 0, 0) ub <- c(100, 0.9, 0.5, 1, 1) difference <- function(k, t, S0, X, r, implvol, q, kappa, rho, eta, theta, v0) { return(HestonCallVec(k,t) - BS_Call(S0, X, t, r, implvol, q)) } y <- function(kappahat, rhohat, et...