//! implements the conversion between swap dates and swap (time) length
        public double swapLength(Date start, Date end)
        {
            Utils.QL_REQUIRE(end > start, () => "swap end date (" + end + ") must be greater than start (" + start + ")");
            double result = (end - start) / 365.25 * 12.0; // month unit

            result  = new ClosestRounding(0).Round(result);
            result /= 12.0; // year unit
            return(result);
        }
Esempio n. 2
0
 public void testClosest()
 {
     for (int i = 0; i < testData.Length; i++)
      {
     int precision = testData[i].precision;
     ClosestRounding closest = new ClosestRounding(precision);
     double calculated = closest.Round(testData[i].x);
     double expected = testData[i].closest;
     if (!Utils.close(calculated, expected, 1))
        Assert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated);
      }
 }
 //! implements the conversion between swap dates and swap (time) length
 public double swapLength(Date start, Date end)
 {
     Utils.QL_REQUIRE(end > start, "swap end date (" + end + ") must be greater than start (" + start + ")");
      double result = (end - start) / 365.25 * 12.0; // month unit
      result = new ClosestRounding(0).Round(result);
      result /= 12.0; // year unit
      return result;
 }