// Handle<YieldTermStructure> discountCurve = Handle<YieldTermStructure>()); public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate, double notionalAmount, IborIndex index, Handle <YieldTermStructure> discountCurve) : base(index.dayCounter(), index.fixingCalendar(), index.businessDayConvention(), index.fixingDays(), new Payoff(), valueDate, maturityDate, discountCurve) { fraType_ = type; notionalAmount_ = notionalAmount; index_ = index; if (notionalAmount <= 0.0) { throw new ApplicationException("notional Amount must be positive"); } // do I adjust this ? // valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_); Date fixingDate = calendar_.advance(valueDate_, -settlementDays_, TimeUnit.Days); forwardRate_ = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once); strikeForwardRate_ = new InterestRate(strikeForwardRate, index.dayCounter(), Compounding.Simple, Frequency.Once); double strike = notionalAmount_ * strikeForwardRate_.compoundFactor(valueDate_, maturityDate_); payoff_ = new ForwardTypePayoff(fraType_, strike); // incomeDiscountCurve_ is irrelevant to an FRA incomeDiscountCurve_ = discountCurve_; // income is irrelevant to FRA - set it to zero underlyingIncome_ = 0.0; index_.registerWith(update); }
///////////////////////////////////////////////////////// //! RateHelper interface public override double impliedQuote() { if (termStructure_ == null) { throw new ArgumentException("term structure not set"); } return(iborIndex_.fixing(fixingDate_, true)); }
protected override void performCalculations() { Date fixingDate = calendar_.advance(valueDate_, -settlementDays_, TimeUnit.Days); forwardRate_ = new InterestRate(index_.fixing(fixingDate), index_.dayCounter(), Compounding.Simple, Frequency.Once); underlyingSpotValue_ = spotValue(); underlyingIncome_ = 0.0; base.performCalculations(); }
public override void initialize(FloatingRateCoupon coupon) { coupon_ = coupon as RangeAccrualFloatersCoupon; Utils.QL_REQUIRE(coupon_ != null, () => "range-accrual coupon required"); gearing_ = coupon_.gearing(); spread_ = coupon_.spread(); Date paymentDate = coupon_.date(); IborIndex index = coupon_.index() as IborIndex; Utils.QL_REQUIRE(index != null, () => "invalid index"); Handle <YieldTermStructure> rateCurve = index.forwardingTermStructure(); discount_ = rateCurve.link.discount(paymentDate); accrualFactor_ = coupon_.accrualPeriod(); spreadLegValue_ = spread_ * accrualFactor_ * discount_; startTime_ = coupon_.startTime(); endTime_ = coupon_.endTime(); observationTimes_ = coupon_.observationTimes(); lowerTrigger_ = coupon_.lowerTrigger(); upperTrigger_ = coupon_.upperTrigger(); observationsNo_ = coupon_.observationsNo(); List <Date> observationDates = coupon_.observationsSchedule().dates(); Utils.QL_REQUIRE(observationDates.Count == observationsNo_ + 2, () => "incompatible size of initialValues vector"); initialValues_ = new InitializedList <double>(observationDates.Count, 0.0); Calendar calendar = index.fixingCalendar(); for (int i = 0; i < observationDates.Count; i++) { initialValues_[i] = index.fixing( calendar.advance(observationDates[i], -coupon_.fixingDays, TimeUnit.Days)); } }
// Handle<YieldTermStructure> discountCurve = Handle<YieldTermStructure>()); public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate, double notionalAmount, IborIndex index, Handle<YieldTermStructure> discountCurve) : base(index.dayCounter(), index.fixingCalendar(), index.businessDayConvention(), index.fixingDays(), new Payoff(), valueDate, maturityDate, discountCurve) { fraType_ = type; notionalAmount_ = notionalAmount; index_ = index; if (notionalAmount <= 0.0) throw new ApplicationException("notional Amount must be positive"); // do I adjust this ? // valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_); Date fixingDate = calendar_.advance(valueDate_, -settlementDays_, TimeUnit.Days); forwardRate_ = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once); strikeForwardRate_ = new InterestRate(strikeForwardRate, index.dayCounter(), Compounding.Simple, Frequency.Once); double strike = notionalAmount_ * strikeForwardRate_.compoundFactor(valueDate_, maturityDate_); payoff_ = new ForwardTypePayoff(fraType_, strike); // incomeDiscountCurve_ is irrelevant to an FRA incomeDiscountCurve_ = discountCurve_; // income is irrelevant to FRA - set it to zero underlyingIncome_ = 0.0; index_.registerWith(update); }