Пример #1
0
        public void testSimple()
        {
            Period[] p = { new Period(3, TimeUnit.Months), new Period(6, TimeUnit.Months), new Period(1, TimeUnit.Years) };
             double[] expected = { 0.25, 0.5, 1.0 };
             int n = p.Length;

             // 4 years should be enough
             Date first= new Date(1,Month.January,2002), last = new Date(31,Month.December,2005);
             DayCounter dayCounter = new SimpleDayCounter();

              for (Date start = first; start <= last; start++)
              {
              for (int i=0; i<n; i++)
              {
                  Date end = start + p[i];
                  double calculated = dayCounter.yearFraction(start,end,null ,null );
                  if (Math.Abs(calculated-expected[i]) > 1.0e-12)
                  {
                      Assert.Fail ("from " + start + " to " + end +
                                   "Calculated: " + calculated +
                                   "Expected:   " + expected[i]);
                  }
              }
              }
        }
Пример #2
0
        public void irData(string name,
                    SquareRootProcess process,
                    double rand,
                    DateTime preDate,
                    DateTime nextDate)
        {
            DayCounter dc = new SimpleDayCounter();

            clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

            clstb.INDEX_CD = name;
            clstb.REF_DT = preDate.ToString("yyyyMMdd");
            clstb.SelectOwn();

            clstb.REF_DT = nextDate.ToString("yyyyMMdd");

            double x0 = clstb.LAST;

            double t0 = 0.0;
            double dt = dc.yearFraction(preDate, nextDate);

            double v = Math.Round(process.evolve(t0, x0, dt, rand), 8);

            clstb.LAST = v;
            clstb.LOW = v;
            clstb.HIGH = v;

            clstb.Insert();

        }