function pe=pricingerror(x,pr,r,T,K,p,S0) % call options have prices p maturities T (in days) and strikes K (all vectors length J) % price of option where underlying has probabilities pr at values xn % e.g. for a single maturity % [x,pr]=aggregate(diff(C),T); %[pr,CO,sk]=calibrate(x,pr,x,S0*(exp(r*T/252)-1)); so that drift is right. % T=T*ones(1,length(K)); pe=[]; xn=x+S0; for j=1:length(T) pe=[pe sum(max(0,xn-K(j)).*pr)]; end pe=exp(-r*T/252).*pe; pe=pe-p; % pe=sum((p-pe).^2);