Exemplo n.º 1
0
 /// <summary>
 /// Computes today's value of an annuity factor for a vanilla
 /// interest rate swap.
 /// </summary>
 /// <param name="forwardSwapRate">Forward swap rate, expressed as a
 /// decimal.
 /// Example: if the forward swap rate is 6.820177%, call the function
 /// with the value 0.006820177.</param>
 /// <param name="dfSwapStart">Discount factor from today to the start
 /// of the swap.
 /// Example: 6M option into a 2YR quarterly swap.
 /// The appropriate discount factor is for the tenor 6M.</param>
 /// <param name="dfSwapEnd">Discount factor from today to the end of
 /// the swap.
 /// Example: 6M option into a 2YR quarterly swap.
 /// The appropriate discount factor is for the tenor (6M + 2YR).</param>
 /// <returns>Annuity factor for a vanilla interest rate swap.</returns>
 public double ComputeAnnuityFactor(double forwardSwapRate,
                                    double dfSwapStart,
                                    double dfSwapEnd)
 {
     return(SwapAnalytics.ComputeAnnuityFactor(forwardSwapRate,
                                               dfSwapStart,
                                               dfSwapEnd));
 }
Exemplo n.º 2
0
        public void ComputeAnnuityFactorTest()
        {
            const double forwardSwapRate = 0.0615; // 6.15%
            const double dfSwapStart     = 0.95;
            const double dfSwapEnd       = 0.80;
            const double Expected        = 2.43902439;
            double       actual          = SwapAnalytics.ComputeAnnuityFactor(forwardSwapRate, dfSwapStart, dfSwapEnd);

            Assert.AreEqual(Expected, actual, 0.00000001);
        }
Exemplo n.º 3
0
        public void TestComputeAnnuityFactor()
        {
            // Test #1: 2M option into a 3YR swap.
            _forwardSwapRate = 6.820177 / 100.0;
            _dfSwapStart     = 0.99437584934;
            _dfSwapEnd       = 0.81178430567;
            _expected        = 2.67723;
            _actual          = SwapAnalytics.ComputeAnnuityFactor(_forwardSwapRate,
                                                                  _dfSwapStart,
                                                                  _dfSwapEnd);

            Assert.AreEqual(_expected, _actual, _tolerance);

            // Test #2: 6M option into a 4YR swap.
            _forwardSwapRate = 6.824469 / 100.0;
            _dfSwapStart     = 0.96673145605;
            _dfSwapEnd       = 0.73858756401;
            _expected        = 3.33348;
            _actual          = SwapAnalytics.ComputeAnnuityFactor(_forwardSwapRate,
                                                                  _dfSwapStart,
                                                                  _dfSwapEnd);

            // Test #3: 5YR option into a 10YR swap.
            _forwardSwapRate = 6.352136 / 100.0;
            _dfSwapStart     = 0.73016181577;
            _dfSwapEnd       = 0.39069662207;
            _expected        = 5.34411;
            _actual          = SwapAnalytics.ComputeAnnuityFactor(_forwardSwapRate,
                                                                  _dfSwapStart,
                                                                  _dfSwapEnd);

            // Test #4: 3YR option into a 7YR swap.
            _forwardSwapRate = 6.507184 / 100.0;
            _dfSwapStart     = 0.81864063634;
            _dfSwapEnd       = 0.52290276017;
            _expected        = 4.54479;
            _actual          = SwapAnalytics.ComputeAnnuityFactor(_forwardSwapRate,
                                                                  _dfSwapStart,
                                                                  _dfSwapEnd);
        }