-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heston Model: Support for Angled Contour Shift Integrals #1826
Merged
Merged
Changes from 27 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
c7efbd6
first light from Heston update
klausspanderen 46011bd
first light from Heston update
klausspanderen f516ebd
added missing file to project definition
klausspanderen cb4c3aa
improve windows build
klausspanderen 33fc781
refactoring: removed doCalculation from AnalyticHestonEngine
klausspanderen 2dbd08b
refactoring: removed unused Fp_Helper constructors
klausspanderen 018df35
secure state
klausspanderen 490c963
secure state
klausspanderen 539c162
Merge remote-tracking branch 'origin/heston_update' into heston_update
klausspanderen c1a9ee4
Merge remote-tracking branch 'origin/heston_update' into heston_update
klausspanderen 7f04a49
finish work on optimal alpha
klausspanderen 360f8da
make alpha optional
klausspanderen f12e6a6
fixed test case on mac os
klausspanderen cc7ec7c
Merge remote-tracking branch 'origin/heston_update' into heston_update
klausspanderen a85fec3
improve Hestson integration
klausspanderen 1070869
fixed windows build
klausspanderen b89e3c0
fixed test case
klausspanderen 74b6f3d
fixed test case
klausspanderen 306fff1
numbers are alright for order 64
klausspanderen f66acb5
.
klausspanderen 445c6dd
change default to angled contour integration
klausspanderen d09386c
.
klausspanderen d5a0711
Merge remote-tracking branch 'origin/heston_update' into heston_update
klausspanderen 0c6cfb1
removed useless includes
klausspanderen 078e5de
removed commented out code
klausspanderen 3b708e9
moved test to fast section
klausspanderen 2de91c2
fixed explicit constructor
klausspanderen b0be193
update papi documentation and initialization
klausspanderen 53863ae
merge with head
klausspanderen 89a6948
fixed parallel benchmark
klausspanderen 96f9c02
Merge remote-tracking branch 'origin/heston_update' into heston_update
klausspanderen 95731b2
use contour integral also for asymptotic control variate
klausspanderen fd23f18
parameter fine-tuning
klausspanderen bc9ae04
eliminate separate enum
klausspanderen 2dfb5b3
bring back deprecated function
klausspanderen 7b7553a
merge
klausspanderen d98f85a
merge
klausspanderen 604308a
merge
klausspanderen c106e66
merge
klausspanderen 57666f2
fixed QL_REQUIRE condition
klausspanderen c1acc8b
Remove executable bit from source file
lballabio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
|
||
/* | ||
Copyright (C) 2023 Klaus Spanderen | ||
|
||
This file is part of QuantLib, a free-software/open-source library | ||
for financial quantitative analysts and developers - http://quantlib.org/ | ||
|
||
QuantLib is free software: you can redistribute it and/or modify it | ||
under the terms of the QuantLib license. You should have received a | ||
copy of the license along with this program; if not, please email | ||
<[email protected]>. The license is also available online at | ||
<http://quantlib.org/license.shtml>. | ||
|
||
This program is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
FOR A PARTICULAR PURPOSE. See the license for more details. | ||
*/ | ||
|
||
#include <ql/math/expm1.hpp> | ||
#include <ql/math/functional.hpp> | ||
|
||
#include <cmath> | ||
|
||
namespace QuantLib { | ||
std::complex<Real> expm1(const std::complex<Real>& z) { | ||
if (std::abs(z) < 1.0) { | ||
const Real a = z.real(), b = z.imag(); | ||
const Real exp_1 = std::expm1(a); | ||
const Real cos_1 = -2*squared(std::sin(0.5*b)); | ||
|
||
return std::complex<Real>( | ||
exp_1*cos_1 + exp_1 + cos_1, | ||
std::sin(b)*std::exp(a) | ||
); | ||
} | ||
else { | ||
return std::exp(z)-1.0; | ||
} | ||
} | ||
|
||
std::complex<Real> log1p(const std::complex<Real>& z) { | ||
const Real a = z.real(), b = z.imag(); | ||
if (std::abs(a) < 0.5 && std::abs(b) < 0.5) { | ||
return std::complex<Real>( | ||
0.5*std::log1p(a*a + 2*a + b*b), | ||
std::arg(1.0 + z) | ||
); | ||
} | ||
else { | ||
return std::log(1.0+z); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
|
||
/* | ||
Copyright (C) 2023 Klaus Spanderen | ||
|
||
This file is part of QuantLib, a free-software/open-source library | ||
for financial quantitative analysts and developers - http://quantlib.org/ | ||
|
||
QuantLib is free software: you can redistribute it and/or modify it | ||
under the terms of the QuantLib license. You should have received a | ||
copy of the license along with this program; if not, please email | ||
<[email protected]>. The license is also available online at | ||
<http://quantlib.org/license.shtml>. | ||
|
||
This program is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
FOR A PARTICULAR PURPOSE. See the license for more details. | ||
*/ | ||
|
||
/*! \file expm1.hpp | ||
\brief complex versions of expm1 and logp1 | ||
*/ | ||
|
||
#ifndef quantlib_expm1_hpp | ||
#define quantlib_expm1_hpp | ||
|
||
#include <ql/types.hpp> | ||
#include <complex> | ||
|
||
namespace QuantLib { | ||
std::complex<Real> expm1(const std::complex<Real>& z); | ||
std::complex<Real> log1p(const std::complex<Real>& z); | ||
} | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These implementations are for real arguments. Without further proof I'd be rather cautious to use the Pde-approximations in the complex plane.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct.
I found this stackoverflow answer giving the same formula. Regard this thread as void if you want.