Skip to content

Commit

Permalink
Fix sign of theta in Kirk spread-option engine
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed May 28, 2021
1 parent d57323f commit 7517e8f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
3 changes: 2 additions & 1 deletion ql/experimental/exoticoptions/kirkspreadoptionengine.cpp
Expand Up @@ -96,7 +96,8 @@ namespace QuantLib {
}

Real callValue = optionType == Option::Call ? results_.value : riskFreeDiscount*(F*Nd1-Nd2)*(forward2+strike);
results_.theta = (log(riskFreeDiscount)/t)*callValue+riskFreeDiscount*(forward1*sigma)/(2*sqrt(t))*pdf(d1);
results_.theta = -((log(riskFreeDiscount)/t)*callValue
+ riskFreeDiscount*(forward1*sigma)/(2*sqrt(t))*pdf(d1));
}

}
Expand Down
38 changes: 19 additions & 19 deletions test-suite/spreadoption.cpp
Expand Up @@ -74,25 +74,25 @@ void SpreadOptionTest::testKirkEngine() {
formula */

Case cases[] = {
{ 28.0, 20.0, 7.0, 0.05, 0.29, 0.36, 0.42, 90, 2.1670, 3.0431 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, -0.5, 36, 4.7530, 25.5905 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.0, 36, 3.7970, 20.8841 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.5, 36, 2.5537, 14.7260 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, -0.5, 180, 10.7517, 10.0847 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.0, 180, 8.7020, 8.2619 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.5, 180, 6.0257, 5.8661 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, -0.5, 36, 5.4275, 28.9013 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.0, 36, 4.3712, 23.7133 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.5, 36, 3.0086, 16.9864 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, -0.5, 180, 12.1941, 11.3603 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.0, 180, 9.9340, 9.3589 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.5, 180, 7.0067, 6.7463 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, -0.5, 36, 5.4061, 28.7963 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.0, 36, 4.3451, 23.5848 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.5, 36, 2.9723, 16.8060 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, -0.5, 180, 12.1483, 11.3200 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.0, 180, 9.8780, 9.3091 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.5, 180, 6.9284, 6.6761 }
{ 28.0, 20.0, 7.0, 0.05, 0.29, 0.36, 0.42, 90, 2.1670, -3.0431 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, -0.5, 36, 4.7530, -25.5905 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.0, 36, 3.7970, -20.8841 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.5, 36, 2.5537, -14.7260 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, -0.5, 180, 10.7517, -10.0847 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.0, 180, 8.7020, -8.2619 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.20, 0.5, 180, 6.0257, -5.8661 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, -0.5, 36, 5.4275, -28.9013 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.0, 36, 4.3712, -23.7133 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.5, 36, 3.0086, -16.9864 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, -0.5, 180, 12.1941, -11.3603 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.0, 180, 9.9340, -9.3589 },
{ 122.0, 120.0, 3.0, 0.10, 0.25, 0.20, 0.5, 180, 7.0067, -6.7463 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, -0.5, 36, 5.4061, -28.7963 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.0, 36, 4.3451, -23.5848 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.5, 36, 2.9723, -16.8060 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, -0.5, 180, 12.1483, -11.3200 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.0, 180, 9.8780, -9.3091 },
{ 122.0, 120.0, 3.0, 0.10, 0.20, 0.25, 0.5, 180, 6.9284, -6.6761 }
};

for (auto& i : cases) {
Expand Down

0 comments on commit 7517e8f

Please sign in to comment.