Package org.jquantlib.termstructures

Examples of org.jquantlib.termstructures.InterestRate


        final Calendar calendar = schedule_.calendar();

        // first period might be short or long
        Date start = schedule_.date(0), end = schedule_.date(1);
        Date paymentDate = calendar.adjust(end, paymentAdjustment_);
        InterestRate rate = couponRates_[0];
        /*@Real*/ double nominal = notionals_[0];
        if (schedule_.isRegular(1)) {
            // TODO: code review :: please verify against QL/C++ code
            QL.require(firstPeriodDayCounter_==null || !firstPeriodDayCounter_.equals(paymentDayCounter_) , "regular first coupon does not allow a first-period day count"); // QA:[RG]::verified // TODO: message
            leg.add(new FixedRateCoupon(nominal, paymentDate, rate, paymentDayCounter_, start, end, start, end));
View Full Code Here


      final Date accrualStartDate, final Date accrualEndDate,
      final Date refPeriodStart, final Date refPeriodEnd) {
    super(nominal, paymentDate, accrualStartDate, accrualEndDate,
        refPeriodStart, refPeriodEnd);

    this.rate = new InterestRate(rate, dayCounter, Compounding.Simple);
    this.dayCounter = dayCounter;
  }
View Full Code Here

      final Date accrualStartDate, final Date accrualEndDate,
      final Date refPeriodStart, final Date refPeriodEnd) {
    super(nominal, paymentDate, accrualStartDate, accrualEndDate,
        refPeriodStart, refPeriodEnd);

    this.rate = new InterestRate(rate, dayCounter, Compounding.Simple);
    this.dayCounter = dayCounter;
  }
View Full Code Here

            this.settlementDate_ = settlementDate;
        }

        @Override
        public double op(final double guess) {
            final InterestRate rate = new InterestRate(guess, dayCounter_, compounding_, frequency_);
            final double NPV = npv(cashflows_, rate, settlementDate_);
            return marketPrice_ - NPV;
        }
View Full Code Here

        this.notionals_ = notionals; // TODO: clone() ?
        return this;
    }

    public FixedRateLeg withCouponRates(/* @Rate */final double couponRate) {
        couponRates_ = new InterestRate[]{new InterestRate(couponRate, paymentDayCounter_, Compounding.Simple)};

        if (System.getProperty("EXPERIMENTAL") == null)
            throw new UnsupportedOperationException("Work in progress");

        //        couponRates_.clear();
View Full Code Here

    }

    public FixedRateLeg withCouponRates(/* @Rate */final double [] couponRates) {
        couponRates_ = new InterestRate[couponRates.length];
        for (int i = 0; i<couponRates.length; i++) {
            couponRates_[i] = new InterestRate(couponRates[i], paymentDayCounter_, Compounding.Simple);
        }
        return this;
    }
View Full Code Here

        final Calendar calendar = schedule_.calendar();

        // first period might be short or long
        Date start = schedule_.date(0), end = schedule_.date(1);
        Date paymentDate = calendar.adjust(end, paymentAdjustment_);
        InterestRate rate = couponRates_[0];
        /*@Real*/ double nominal = notionals_[0];
        if (schedule_.isRegular(1)) {
            // TODO: code review :: please verify against QL/C++ code
            QL.require(firstPeriodDayCounter_==null || !firstPeriodDayCounter_.equals(paymentDayCounter_) , "regular first coupon does not allow a first-period day count"); // TODO: message
            leg.add(new FixedRateCoupon(nominal, paymentDate, rate, paymentDayCounter_, start, end, start, end));
View Full Code Here

                                  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().clone();
                } else {
                    final Object cpnObj = cashflows.get(i);
                  final Coupon coupon = Coupon.class.isAssignableFrom(cpnObj.getClass()) ? (Coupon)cpnObj : null;
                    if (coupon != null) {
                        lastDate = coupon.accrualStartDate().clone();
                    } else {
                        lastDate = couponDate.sub(new Period(1, TimeUnit.Years));
                    }
                }
                discount *= y.discountFactor(settlement, couponDate, lastDate, couponDate);
            } else {
                discount *= y.discountFactor(lastDate, couponDate);
            }
            lastDate = couponDate.clone();

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

        // 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

    }

    @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

Related Classes of org.jquantlib.termstructures.InterestRate

Copyright © 2018 www.massapicom. 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.