[R] Problem with integration on Heston model
Guaramy
Guaramy at hotmail.com
Thu Apr 19 19:38:43 CEST 2012
Hi ,
I am writing some code to evaluate a price of an option with heston model.
My problem is that i need one variable to be generic .
Hestonf = function(phi,kappa,theta,sigma,rho,v0,r,T,s0,type)
{
if (type == 1)
{
u = 0.5;
b = kappa-rho*sigma;
}
else {
u = 0.5;
b = kappa;
}
a = kappa * theta;
x = log(s0);
d = sqrt((rho*sigma*phi*
complex(1,0,1)-b)^2-sigma^2*(2*u*phi*complex(1,0,1)^2));
g = (b-rho*sigma*phi*complex(1,0,1)+d)/(b-rho*sigma*phi*complex(1,0,1)-d);
C = r*phi*complex(1,0,1)*T +
a/sigma^2*((b-rho*sigma*phi*complex(1,0,1)+d)-2*log((1-g*exp(d*T))/(1-g)));
D =
(b-rho*sigma*phi*complex(1,0,1)+d)/(sigma^2)*((1-exp(d*T))/(1-g*exp(d*T)));
f = exp((C+D*v0 + complex(1,0,1)*phi*x));
this code here constructs the function to be integrated . My problem is that
i need phi to be a generic variable ir order to integrate it in a interval
HestonIntegralP = function (phi,kappa,theta,sigma,rho,V0,r,T,so,K,type)
{
ret =
Re(exp(-complex(1,0,1)*phi*log(K))*Hestonf(phi,kappa,theta,sigma,rho,v0,r,T,s0,type)/(complex(1,0,1)*phi));
ret
}
this code is the final function to integrate.
After this just need to use some numerical tecnic integration to obtain my
needed results.
In sum i need to construct a function and integrate in order to phi generic
variable.
Sorry for the newbie question but i already have tried almost everything
--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-integration-on-Heston-model-tp4571628p4571628.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list