I am running an optimization procedure using Fminsearch. It would be too complicated to post all the code here (and I cannot share everything for confidentiality), but I'll give a good description and hopefully you can give me some general ideas on why this issue is happening.
Basically, I have data on option prices and implied volatility for a given time period. Separately, I have divided this data into blocks of x weeks. For each of these blocks, I use fminsearch to solve for a set of x parameters that minimizes the mean-squared error of a very complicated function. Sorry that I cannot give more details here.
I have set the options as such:
`options = optimset('MaxFunEvals',5000, 'TolFun', 1e-2);`
When I run the fminsearch for each block, the code is:
[a,fval,exitflag,options] = fminsearch(fun,x0,options)
The problem is that the optimization always stops prematurely. It does not respect my set maximum number of iterations, nor my set tolerance level. It always exits before, with fval >> TolFun and number of iterations << MaxFunEvals.
If useful to know, the fminsearch is embedded within a defined function, which I call as I loop through the blocks of weeks:
function [mu,fval,exitflag,options] = estimate(mu_prev, strike, close, m, n, call_prices, x1, options)
t2 = tic;
pen_fun = @(x) ...;
[a,fval,exitflag,options] = fminsearch(pen_fun,x1,options);
toc(t2)
Any ideas?
I've tried to move the options within the loop or within the function, but to no avail