search for: bs_call

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

2011 Aug 16
2
Calibrating the risk free interest rate using nlminb
...;- 0.02145608 S0 <- spot[10,6] S0 strike <- marketdata[1:460,9] T <- marketdata[1:460,17]/365 #Notice the T is measured in years now implvol <- marketdata[1:460,12] ask <- marketdata[1:460,10] bid <- marketdata[1:460,11] mid_bidask <- (bid + ask) /2 r <- 0.020 And my code: BS_Call <- function(S0, K, T, r, sigma, q) # Which works fine { sig <- sigma * sqrt(T) d1 <- (log (S0/K) + (r - q + sigma^2/2) * T ) / sig d2 <- d1 - sig Presentvalue <- exp(-r*T) return (S0 * exp(-q*T) * pnorm(d1) - K*Presentvalue*pnorm(d2)) } #I now define the funct...
2011 Aug 18
3
Error message: object of type 'closure' is not subsettable
...ing 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, etahat, thetahat, v0hat) {sum(difference(k, t, S0, X, r, implvol, q, kappahat, rhohat, etahat, thetahat, v0hat)^2)} nlminb(start=list(kappa, rho, eta, theta, v0), objective = y, lower =lb, upper =ub) -- View this message in context: h...