Ejemplo n.º 1
0
        //! 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);
        }
Ejemplo 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);
      }
 }
Ejemplo n.º 3
0
 //! 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;
 }