How to restrict the domain of a function?

I'm trying to optimize the parameters of different pricing model by applying functions as restrictions.

Unfortunately, my approach only restricts the codomain of those functions, while the domain remains wide open (and for most cases, it's infinite, so that results in a broken optimization).

Is there a way for me to restrict the domain of a certain function? Below you have the example for Black-Scholes, where the codomain of the theta parameter function is (0,1) but the domain is infinite, and I would like the domain to be [-1,1]:

new;
library optmum,pgraph;
pqgwin many;
load data[]=D:\Disertatie\Data.txt;
data=reshape(data,rows(data)./6,6);
data=delif(data,data[.,6].<=6);
data=delif(data,data[.,2].<=3/8);
data=delif(data,data[.,3]./data[.,4].>=5);

r=data[.,5]/100;
tau=data[.,6]/365;
S=data[.,3];
K=data[.,4];

pret_real=data[.,2];

proc bscall(sigma);
    local d1,d2,c;

    d1=(ln(S./K)+(r+0.5.*sigma^2).*tau)./(sigma.*sqrt(tau));
    d2=d1-sigma.*sqrt(tau);
    c=S.*cdfn(d1)-K.*exp(-r.*tau).*cdfn(d2);

    retp(c);
endp;

proc eroare(&f,theta);
    local f:proc;
    theta=(cos((0.2.*theta)./pi))*sin(theta./(0.2.*pi));
    retp(f(theta)-pret_real);
endp;

proc eroare_patrat_bs(theta);
    retp(sumc(eroare(&bscall,theta).^2));
endp;

proc implicit_bs(theta);
    local x,y,gradient,retcode;
    {x,y,gradient,retcode}=optmum(&eroare_patrat_bs,theta);
    x=(cos((0.2.*x)./pi))*sin(x./(0.2.*pi));
    retp(x);
endp;

xbs=0.2;
para=0;
bs=0;
i=data[1,1]; /* prima zi din esantion */
datas=data;
do while i <= data[rows(data),1];
    datam=selif(data,data[.,1].==i);
    datas=delif(datas,datas[.,1].==i);
    i=datas[1,1];
    s=datam[.,3];
    k=datam[.,4];
    r=datam[.,5]./100;
    tau=datam[.,6]./365;
    pret_real=datam[.,2];
    param=implicit_bs(xbs);
    para=para|param;
    bs=bs|bscall(param);
endo;

bs=trim(bs,1,0);
vol=trim(para,1,0);
err=bs-data[.,2];

dataf=data~err;
s=dataf[.,3];
k=dataf[.,4];
pret_real=dataf[.,2];

Thank you!

Cosmin Dobrin

1 Answer



0



I don't think Optmum has an option to control bounds. The updated version Optimization MT (OPTMT) does have the option to set bounds on the parameters.

If you have bought Optmum any time in the last few years, you should also have access to the OPTMT application.

aptech

1,773

Your Answer

1 Answer

0

I don't think Optmum has an option to control bounds. The updated version Optimization MT (OPTMT) does have the option to set bounds on the parameters.

If you have bought Optmum any time in the last few years, you should also have access to the OPTMT application.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.