Examples of InterestRate


Examples of com.opengamma.analytics.financial.interestrate.InterestRate

  public static YieldPeriodicCurve fromYieldsInterpolated(final double[] nodePoints, final double[] yields, final int compoundingPeriodsPerYear, final Interpolator1D interpolator, final String name) {
    final int nbYields = yields.length;
    ArgumentChecker.isTrue(nodePoints.length == nbYields, "Yields array of incorrect length");
    final double[] yieldPeriodic = new double[nbYields];
    for (int loopy = 0; loopy < nbYields; loopy++) {
      final InterestRate continous = new ContinuousInterestRate(yields[loopy]);
      yieldPeriodic[loopy] = continous.toPeriodic(compoundingPeriodsPerYear).getRate();
    }
    final InterpolatedDoublesCurve curve = new InterpolatedDoublesCurve(nodePoints, yieldPeriodic, interpolator, false);
    return new YieldPeriodicCurve(name, compoundingPeriodsPerYear, curve);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.InterestRate

  @Override
  public double getPeriodicInterestRate(final double t, final int compoundingPeriodsPerYear) {
    if (compoundingPeriodsPerYear == _compoundingPeriodsPerYear) {
      _curve.getYValue(t);
    }
    final InterestRate rc = new PeriodicInterestRate(_curve.getYValue(t), _compoundingPeriodsPerYear);
    // Implementation note: rate in the composition of the storage.
    final InterestRate rq = rc.toPeriodic(compoundingPeriodsPerYear);
    return rq.getRate();
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.InterestRate

  public double parRate(final DepositZero deposit, final YieldCurveBundle curves) {
    final YieldAndDiscountCurve dsc = curves.getCurve(deposit.getDiscountingCurveName());
    final double startTime = deposit.getStartTime();
    final double endTime = deposit.getEndTime();
    final double rcc = Math.log(dsc.getDiscountFactor(startTime) / dsc.getDiscountFactor(endTime)) / deposit.getPaymentAccrualFactor();
    final InterestRate rate = deposit.getRate().fromContinuous(new ContinuousInterestRate(rcc));
    return rate.getRate();
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.InterestRate

    ArgumentChecker.notNull(deposit, "deposit");
    ArgumentChecker.notNull(curves, "curves");
    final double dfStart = curves.getCurve(deposit.getDiscountingCurveName()).getDiscountFactor(deposit.getStartTime());
    final double dfEnd = curves.getCurve(deposit.getDiscountingCurveName()).getDiscountFactor(deposit.getEndTime());
    final double ccrs = Math.log(deposit.getInitialAmount() * dfStart / (deposit.getNotional() * dfEnd)) / deposit.getPaymentAccrualFactor();
    final InterestRate rs = deposit.getRate().fromContinuous(new ContinuousInterestRate(ccrs));
    return rs.getRate() - deposit.getRate().getRate();
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.InterestRate

    final Currency currency = security.getCurrency();
    final ZonedDateTime startDate = security.getStartDate();
    final ZonedDateTime endDate = security.getMaturityDate();
    final ConventionBundle convention = _conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, currency.getCode() + "_ZERO_DEPOSIT"));
    final DayCount daycount = convention.getDayCount();
    final InterestRate rate = new ContinuousInterestRate(security.getRate());
    final Calendar calendar = new HolidaySourceCalendarAdapter(_holidaySource, currency);
    return DepositZeroDefinition.from(currency, startDate, endDate, daycount, rate, calendar);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.InterestRate

    final Currency currency = security.getCurrency();
    final ZonedDateTime startDate = security.getStartDate();
    final ZonedDateTime endDate = security.getMaturityDate();
    final ConventionBundle convention = _conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, currency.getCode() + "_ZERO_DEPOSIT"));
    final DayCount daycount = convention.getDayCount();
    final InterestRate rate = new PeriodicInterestRate(security.getRate(), (int) security.getCompoundingPeriodsPerYear());
    final Calendar calendar = new HolidaySourceCalendarAdapter(_holidaySource, currency);
    return DepositZeroDefinition.from(currency, startDate, endDate, daycount, rate, calendar);
  }
View Full Code Here

Examples of org.jquantlib.termstructures.InterestRate

      // The tolerance is high because Andima truncate yields
      final double tolerance = 1.0e-4;

      final InterestRate [] couponRates = new InterestRate[1];
      couponRates[0] = new InterestRate(0.1,new Thirty360(),Compounding.Compounded,Frequency.Annual);

      for (int bondIndex = 0; bondIndex < maturityDates.length; bondIndex++) {

          // plain
          final InterestRate yield = new InterestRate(yields[bondIndex],
                             new Business252(new Brazil()),
                             Compounding.Compounded, Frequency.Annual);

          final Schedule schedule = new Schedule(new Date(1,Month.January,2007),
                            maturityDates[bondIndex], new Period(Frequency.Semiannual),
                            new Brazil(Brazil.Market.SETTLEMENT),
                            BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                            DateGeneration.Rule.Backward, false);

          // fixed coupons
          final Leg cashflows =
              new FixedRateLeg(schedule, new Actual360())
              .withNotionals(faceAmount)
              .withCouponRates(couponRates)
              .withPaymentAdjustment(BusinessDayConvention.ModifiedFollowing).Leg();
          // redemption
          cashflows.add(new SimpleCashFlow(faceAmount, cashflows.last().date()));

          final Bond bond = new Bond(settlementDays, new Brazil(Brazil.Market.SETTLEMENT),
                    faceAmount, cashflows.last().date(),
                    new Date(1,Month.January,2007), cashflows);

          final double cachedPrice = prices[bondIndex];

          final double price = faceAmount*bond.dirtyPrice(yield.rate(),
                                                       yield.dayCounter(),
                                                       yield.compounding(),
                                                       yield.frequency(),
                                                       today)/100;
          if (Math.abs(price-cachedPrice) > tolerance) {
              fail("failed to reproduce cached price:\n"
                          + "    calculated: " + price + "\n"
                          + "    expected:   " + cachedPrice + "\n"
View Full Code Here

Examples of org.jquantlib.termstructures.InterestRate

            final Compounding compounding, Frequency frequency, final Date settlement) {
        if (frequency == Frequency.NoFrequency || frequency == Frequency.Once) {
            frequency = Frequency.Annual;
        }

        final InterestRate y = new InterestRate(yield, dayCounter, compounding,
                frequency);

        /* @Real */double price = 0.0;
        /* @DiscountFactor */double discount = 1.0;
        Date lastDate = new Date();

        for (int i = 0; i < cashflows.size(); ++i) {
            if (cashflows.get(i).hasOccurred(settlement)) {
                continue;
            }

            final Date couponDate = cashflows.get(i).date();
            /* @Real */final double amount = cashflows.get(i).amount();

            if (lastDate.isNull()) {
                // first not-expired coupon
                if (i > 0) {
                    lastDate = cashflows.get(i - 1).date();
                } else {
                    // Coupon coupon = (Coupon )cashflows.get(i);
                    final CashFlow coupon = cashflows.get(i);
                    if (coupon instanceof Coupon && coupon != null) {
                        // if (coupon)
                        lastDate = ((Coupon) coupon).accrualStartDate();
                    } else {
                        lastDate = couponDate.sub(new Period(1, TimeUnit.Years));
                    }
                }
                discount *= y.discountFactor(settlement, couponDate, lastDate,
                        couponDate);
            } else {
                discount *= y.discountFactor(lastDate, couponDate);
            }
            lastDate = couponDate;

            price += amount * discount;
        }
View Full Code Here

Examples of org.jquantlib.termstructures.InterestRate

        // do I adjust this ?
        // valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_);
        final Date fixingDate = calendar.advance (valueDate, -1 * settlementDays, TimeUnit.Days);

        forwardRate = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once);
        this.strikeForwardRate = new InterestRate(strikeForwardRate, index.dayCounter(), Compounding.Simple, Frequency.Once);
        final double strike = notional * this.strikeForwardRate.compoundFactor(valueDate, maturityDate);
        payoff = new ForwardTypePayoff(fraType, strike);

        // income discount curve is irrelevant to a FRA
        incomeDiscountCurve = discountCurve;
View Full Code Here

Examples of org.jquantlib.termstructures.InterestRate

    }

    @Override
    public void performCalculations() {
        final Date fixingDate = calendar.advance(valueDate, -1 * settlementDays, TimeUnit.Days);
        forwardRate = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once);
        underlyingSpotValue = spotValue();
        underlyingIncome = 0.0;
        super.performCalculations();
    }
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.