Examples of Flag


Examples of org.jquantlib.testsuite.util.Flag

    public void testNotificationSubAssign() {

        QL.info("Testing observability of dates using operation Date#subAssign()");

        final Date me = Date.todaysDate();
        final Flag f = new Flag();
        me.addObserver(f);
        me.subAssign(1);
        if (!f.isUp()) {
            fail("Observer was not notified of date change");
        }
    }
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

    public void testNotificationSub() {

        QL.info("Testing observability of dates using operation Date#sub()");

        final Date me = Date.todaysDate();
        final Flag f = new Flag();
        me.addObserver(f);
        me.sub(1);
        if (f.isUp()) {
            fail("Observer was notified of date change whilst it was not expected");
        }
    }
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

        QL.info("Testing notification of date handles...");

        final Date me1 = Date.todaysDate();
        final RelinkableHandle<Date> h = new RelinkableHandle<Date>(me1);

        final Flag f = new Flag();
        h.addObserver(f);

        final Date weekAgo = Date.todaysDate().sub(7);
        final Date me2 = weekAgo;

        h.linkTo(me2);
        if (!f.isUp()) {
            fail("Observer was not notified of date change");
        }

        if (h.currentLink() != weekAgo) {
            fail("Failed to hard link to another object");
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

        QL.info("Testing notification of date handles using operation Date#subAssign().");

        final Date me1 = Date.todaysDate();
        final RelinkableHandle<Date> h = new RelinkableHandle<Date>(me1);

        final Flag f = new Flag();
        h.addObserver(f);

        me1.subAssign(1);
        if (!f.isUp()) {
            fail("Observer was not notified of date change");
        }
    }
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

        QL.info("Testing ntification of date handles using operation Date#sub().");

        final Date me1 = Date.todaysDate();
        final RelinkableHandle<Date> h = new RelinkableHandle<Date>(me1);

        final Flag f = new Flag();
        h.addObserver(f);

        me1.sub(1);
        if (f.isUp()) {
            fail("Observer was notified of date change whilst it was not expected");
        }
    }
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

                      Discount.class, LogLinear.class, IterativeBootstrap.class,
                      vars.settlementDays,
                      vars.calendar,
                          vars.instruments,
                          new Actual360());
      final Flag f = new Flag();
      vars.termStructure.addObserver(f);

      for (int i=0; i<vars.deposits+vars.swaps; i++) {
          /*@Time*/ final double testTime = new Actual360().yearFraction(vars.settlement, vars.instruments[i].latestDate());
          /*@DiscountFactor*/ final double discount = vars.termStructure.discount(testTime);
          f.lower();
          vars.rates[i].setValue(vars.rates[i].value()*1.01);
          if (!f.isUp())
              throw new RuntimeException("Observer was not notified of underlying rate change");
          if (vars.termStructure.discount(testTime,true) == discount)
            throw new RuntimeException("rate change did not trigger recalculation");
          vars.rates[i].setValue(vars.rates[i].value()/1.01);
      }

      f.lower();
      new Settings().setEvaluationDate(vars.calendar.advance(vars.today, 15, TimeUnit.Days));
      if (!f.isUp())
        throw new RuntimeException("Observer was not notified of date change");
  }
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

                          "    estimated rate: ", estimatedRate, "\n",
                          "    expected rate:  ", expectedRate));
          }
      }

      final Flag f = new Flag();
      vars.termStructure.addObserver(f);
      f.lower();

      index.addFixing(vars.today, 0.0425);

      if (!f.isUp())
          throw new RuntimeException("Observer was not notified of rate fixing");

      for (int i=0; i<vars.swaps; i++) {
          final Period tenor = new Period(swapData[i].n, swapData[i].units);
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

                    }
                } );

        final YieldTermStructure implied = new ImpliedTermStructure<YieldTermStructure>(h, newSettlement);

        final Flag flag = new Flag();
        implied.addObserver(flag);

        // TODO: initialization needed (dependent of PiecewiseYieldCurve)
        // h.setLink(termStructure);

        // -------------------------------------------------------------------------------------------------------------
        // FIXME: This code was added instead. Please remove when PiecewiseYieldCurve becomes ready
        //
        final Quote quote = new SimpleQuote(100.0);
        final Flag anotherFlag = new Flag();
        quote.addObserver(anotherFlag);
        h.linkTo(new FlatForward(today, new Handle<Quote>(quote), new Actual360()));
        if (!anotherFlag.isUp()) {
            fail("Observer was not notified of term structure change");
        }

        if (!flag.isUp()) {
            fail("Observer was not notified of term structure change");
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

  public void testObservable() {

      QL.info("Testing observability of quotes...");

      final SimpleQuote me = new SimpleQuote(0.0);
      final Flag f = new Flag();
      me.addObserver(f);
      me.setValue(3.14);
      if (!f.isUp()) {
            fail("Observer was not notified of quote change");
        }
  }
View Full Code Here

Examples of org.jquantlib.testsuite.util.Flag

    QL.info("Testing observability of quote handles...");

      final SimpleQuote me1 = new SimpleQuote(0.0);
      final RelinkableHandle<Quote> h = new RelinkableHandle(me1);

      final Flag f = new Flag();
      h.addObserver(f);

      me1.setValue(3.14);
      if (!f.isUp()) {
            fail("Observer was not notified of quote change");
        }

      f.lower();
      final SimpleQuote me2 = new SimpleQuote(0.0);

      h.linkTo(me2);
      if (!f.isUp()) {
            fail("Observer was not notified of quote change");
        }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.