Calibrating VIX option data to model - lsqnonlin problem
Show older comments
Im new to MatLab and in the process of learning it. Currently im trying to calibrate VIX option market data to Mean-reverting volatility process. To begin with im just trying to get an output without errors.
I have coded this script and the following function: ___________________________________________________________________________ clear all
load('callopt.mat');
global K; global T; global r; global market;
%K=strike, T=time to expiration in year fraction %market=market option prices
K=callopt(:,3); T=callopt(:,2); market=callopt(:,10); r=0.01;
x0=[2,2,2,2];
[x,resnorm]=lsqnonlin(@myfun,x0); ___________________________________________________________________________
function F=myfun(bet,rev,V,sig)
global K; global T; global r; global market;
vega=4*rev*bet./(sig^2);
gam=(4*bet)./((sig^2)*(1-exp(-bet*T)));
lambda=vega*exp(-bet*T)*V;
model=exp(-r.*T).*(exp(-bet.*T).*V.*ncx2cdf(gam.*K,vega+4,lambda))+rev.*(1-exp(-bet.*T)).*ncx2cdf(gam.*K,vega+2,lambda)-K.*ncx2cdf(gam.*K,vega,lambda);
F=(market-model); ___________________________________________________________________________
This is the complete error i receive: Error using myfun (line 5) Not enough input arguments.
Error in lsqnonlin (line 197) initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Error in meanrev (line 15) [x,resnorm]=lsqnonlin(@myfun,x0); Caused by: Failure in initial user-supplied objective function evaluation. LSQNONLIN cannot continue.
Can someone help?
Accepted Answer
More Answers (0)
Categories
Find more on Financial Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!