22
33#include < gtest/gtest.h>
44
5+ #include " rates/zero_curve.h"
6+
57namespace smileexplorer {
68namespace {
79
@@ -23,13 +25,19 @@ TEST(TargetRedemptionForwardTest, AtmForward) {
2325 strip of forwards. For reference, the accumulated profit of the profitable
2426 forwards would be 48mm ISK.
2527 */
28+ ZeroSpotCurve domestic_curve (
29+ {1 , 3 }, {0.08 , 0.08 }, CompoundingPeriod::kContinuous );
30+ ZeroSpotCurve foreign_curve (
31+ {1 , 3 }, {0.04 , 0.04 }, CompoundingPeriod::kContinuous );
32+
2633 const double expected_npv = 0 .;
2734 const double error_threshold = 20000 ;
2835
2936 TargetRedemptionForward tarf (1e6 , 100e6 , 135.657 , 4.0 , 0.25 );
3037
3138 for (int i = 0 ; i < 5 ; ++i) {
32- double npv = tarf.price (125 ., 0.0004 , 0.1 , 10000 );
39+ double npv =
40+ tarf.price (125 ., 0.0004 , 0.1 , 10000 , foreign_curve, domestic_curve);
3341 EXPECT_LT (std::abs (npv - expected_npv), error_threshold);
3442 }
3543}
@@ -44,12 +52,51 @@ TEST(TargetRedemptionForwardTest, OtmForward) {
4452 in an NPV of almost exactly 50mm ISK.
4553 */
4654
55+ ZeroSpotCurve domestic_curve (
56+ {1 , 3 }, {0.08 , 0.08 }, CompoundingPeriod::kContinuous );
57+ ZeroSpotCurve foreign_curve (
58+ {1 , 3 }, {0.04 , 0.04 }, CompoundingPeriod::kContinuous );
59+
4760 const double expected_npv = 50e6 ;
4861 const double error_threshold = 20000 ;
4962
5063 TargetRedemptionForward tarf (1e6 , 100e6 , 131.9686 , 4.0 , 0.25 );
5164 for (int i = 0 ; i < 5 ; ++i) {
52- double npv = tarf.price (125 ., 0.0004 , 0.1 , 10000 );
65+ double npv =
66+ tarf.price (125 ., 0.0004 , 0.1 , 10000 , foreign_curve, domestic_curve);
67+
68+ EXPECT_LT (std::abs (npv - expected_npv), error_threshold);
69+ }
70+ }
71+
72+ TEST (TargetRedemptionForwardTest, KnockoutAlmostDeterministic) {
73+ /*
74+ Similar to the AtmForward case above, but with a 6mm ISK cumulative profit
75+ target. At a very low vol, this is almost certain to happen at year 2.75 (with
76+ positive payments at t=[2.25, 2.5, 2.75]).
77+
78+ The expected NPV is very negative here, because we are using the ATM fwd as
79+ the strike, yet we have a fairly low profit target and a large interest-rate
80+ differential. Therefore, there are large accumulated losses in the first 2
81+ years (around -39mm ISK, not discounted) and only +6mm ISK worth of profits
82+ due to the fixed target.
83+ */
84+
85+ ZeroSpotCurve domestic_curve (
86+ {1 , 3 }, {0.08 , 0.08 }, CompoundingPeriod::kContinuous );
87+ ZeroSpotCurve foreign_curve (
88+ {1 , 3 }, {0.04 , 0.04 }, CompoundingPeriod::kContinuous );
89+
90+ // This is the discounted amount of the approx. -33mm in total losses (-39mm +
91+ // 6mm):
92+ const double expected_npv = -31.75e6 ;
93+ const double error_threshold = 20000 ;
94+
95+ TargetRedemptionForward tarf (1e6 , 6e6 , 135.657 , 4.0 , 0.25 );
96+
97+ for (int i = 0 ; i < 5 ; ++i) {
98+ double npv =
99+ tarf.price (125 ., 0.0004 , 0.1 , 10000 , foreign_curve, domestic_curve);
53100 EXPECT_LT (std::abs (npv - expected_npv), error_threshold);
54101 }
55102}
0 commit comments