Skip to content

Commit

Permalink
fixed reference
Browse files Browse the repository at this point in the history
  • Loading branch information
klausspanderen committed May 26, 2020
1 parent 8d7460b commit 2db18d2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 50 deletions.
67 changes: 29 additions & 38 deletions ql/pricingengines/vanilla/analytichestonengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,30 @@ namespace QuantLib {
// helper class for integration
class AnalyticHestonEngine::Fj_Helper {
public:
Fj_Helper(const VanillaOption::arguments& arguments,
const ext::shared_ptr<HestonModel>& model,
const AnalyticHestonEngine* engine,
ComplexLogFormula cpxLog,
Time term,
Real ratio,
Size j);

Fj_Helper(Real kappa,
Real theta,
Real sigma,
Real v0,
Real s0,
Real rho,
const AnalyticHestonEngine* engine,
ComplexLogFormula cpxLog,
Time term,
Real strike,
Real ratio,
Size j);

Fj_Helper(Real kappa,
Real theta,
Real sigma,
Real v0,
Real s0,
Real rho,
ComplexLogFormula cpxLog,
Time term,
Real strike,
Real ratio,
Size j);

Real operator()(Real phi) const;
Fj_Helper(const VanillaOption::arguments& arguments,
const ext::shared_ptr<HestonModel>& model,
const AnalyticHestonEngine* const engine,
ComplexLogFormula cpxLog,
Time term, Real ratio, Size j);

Fj_Helper(Real kappa, Real theta, Real sigma,
Real v0, Real s0, Real rho,
const AnalyticHestonEngine* const engine,
ComplexLogFormula cpxLog,
Time term,
Real strike,
Real ratio,
Size j);

Fj_Helper(Real kappa, Real theta, Real sigma,
Real v0, Real s0, Real rho,
ComplexLogFormula cpxLog,
Time term,
Real strike,
Real ratio,
Size j);

Real operator()(Real phi) const;

private:
const Size j_;
Expand Down Expand Up @@ -268,8 +258,8 @@ namespace QuantLib {
std::sqrt(t1*t1 - sigma2_*phi
*std::complex<Real>(-phi, (j_== 1)? 1 : -1));
const std::complex<Real> ex = std::exp(-d*term_);
const std::complex<Real> addOnTerm =
engine_ != 0 ? engine_->addOnTerm(phi, term_, j_) : Real(0.0);
const std::complex<Real> addOnTerm
= engine_ ? engine_->addOnTerm(phi, term_, j_) : Real(0.0);

if (cpxLog_ == Gatheral) {
if (phi != 0.0) {
Expand Down Expand Up @@ -756,9 +746,10 @@ namespace QuantLib {
}

Size AnalyticHestonEngine::Integration::numberOfEvaluations() const {
if (integrator_ != 0) {
if (integrator_) {
return integrator_->numberOfEvaluations();
} else if (gaussianQuadrature_ != 0) {
}
else if (gaussianQuadrature_) {
return gaussianQuadrature_->order();
}
else {
Expand Down
10 changes: 3 additions & 7 deletions ql/pricingengines/vanilla/analytichestonengine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,11 @@ namespace QuantLib {
Real spotPrice,
Real strikePrice,
Real term,
Real kappa,
Real theta,
Real sigma,
Real v0,
Real rho,
Real kappa, Real theta, Real sigma, Real v0, Real rho,
const TypePayoff& type,
const Integration& integration,
ComplexLogFormula cpxLog,
const AnalyticHestonEngine* enginePtr,
const ComplexLogFormula cpxLog,
const AnalyticHestonEngine* const enginePtr,
Real& value,
Size& evaluations);

Expand Down
11 changes: 6 additions & 5 deletions test-suite/hestonmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2563,8 +2563,8 @@ void HestonModelTest::testPiecewiseTimeDependentComparison() {
Real priceS = 0.0;

for (Size j=0; j < 2; ++j) {
const sample_type& path1 =
(j & 1) != 0u ? firstPathGen.antithetic() : firstPathGen.next();
const sample_type& path1 = (j&1) ? firstPathGen.antithetic()
: firstPathGen.next();
const Real spot1 = path1.value[0].back();
const Real v1 = path1.value[1].back();

Expand Down Expand Up @@ -2887,7 +2887,7 @@ void HestonModelTest::testSmallSigmaExpansion4ExpFitting() {
const Real kappas[] = { 0.5, 1.0, 4.0 };
const Real thetas[] = { 0.04, 0.09};
const Real v0s[] = { 0.025, 0.20 };
const Integer maturities[] = { 1, 31, 182, 1850 };
const Real maturities[] = { 1, 31, 182, 1850 };

for (Size m=0; m < LENGTH(maturities); ++m) {
const Date maturityDate = todaysDate + Period(maturities[m], Days);
Expand Down Expand Up @@ -3058,8 +3058,9 @@ void HestonModelTest::testExponentialFitting4StrikesAndMaturities() {

for (Size k=0; k < 2; ++k) {
const ext::shared_ptr<PlainVanillaPayoff> payoff =
ext::make_shared<PlainVanillaPayoff>((k) != 0u ? Option::Put : Option::Call,
strike);
ext::make_shared<PlainVanillaPayoff>(
(k) ? Option::Put : Option::Call,
strike);

VanillaOption option(payoff, exercise);
option.setPricingEngine(engine);
Expand Down

0 comments on commit 2db18d2

Please sign in to comment.