public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, int fixingDays, List <double> gearings, List <double> spreads, List <double> caps, List <double> floors, bool inArrears, double redemption, Date issueDate) : base(settlementDays, schedule.calendar(), issueDate) { maturityDate_ = schedule.endDate(); cashflows_ = new IborLeg(schedule, index) .withPaymentDayCounter(paymentDayCounter) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List <double>() { redemption }); if (cashflows().Count == 0) { throw new ApplicationException("bond with no cashflows!"); } if (redemptions_.Count != 1) { throw new ApplicationException("multiple redemptions created"); } index.registerWith(update); }
protected ConvertibleBond( Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle<Quote> creditSpread, Date issueDate, int settlementDays, Schedule schedule, double redemption) : base(settlementDays, schedule.calendar(), issueDate) { conversionRatio_ = conversionRatio; callability_ = callability; dividends_ = dividends; creditSpread_ = creditSpread; maturityDate_ = schedule.endDate(); if (!callability.empty()) { Utils.QL_REQUIRE( callability.Last().date() <= maturityDate_, () => "last callability date (" + callability.Last().date() + ") later than maturity (" + maturityDate_.ToShortDateString() + ")"); } creditSpread.registerWith(update); }
public AmortizingFixedRateBond( int settlementDays, List <double> notionals, Schedule schedule, List <InterestRate> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, Date issueDate = null) : base(settlementDays, schedule.calendar(), issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; schedule_ = schedule; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons) .withNotionals(notionals) .withPaymentAdjustment(paymentConvention).value(); addRedemptionsToCashflows(); Utils.QL_REQUIRE(!cashflows().empty(), () => "bond with no cashflows!"); }
public AmortizingFixedRateBond( int settlementDays, List<double> notionals, Schedule schedule, List<double> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, Date issueDate = null) :base(settlementDays, schedule.calendar(), issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; schedule_ = schedule; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, accrualDayCounter) .withNotionals(notionals) .withPaymentAdjustment(paymentConvention).value(); addRedemptionsToCashflows(); if ( cashflows().empty()) throw new ApplicationException("bond with no cashflows!"); }
public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, int fixingDays, List<double> gearings, List<double> spreads, List<double> caps, List<double> floors, bool inArrears, double redemption, Date issueDate) : base(settlementDays, schedule.calendar(), issueDate) { maturityDate_ = schedule.endDate(); cashflows_ = new IborLeg(schedule, index) .withPaymentDayCounter(paymentDayCounter) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List<double>() { redemption }); if (cashflows().Count == 0) throw new ApplicationException("bond with no cashflows!"); if (redemptions_.Count != 1) throw new ApplicationException("multiple redemptions created"); index.registerWith(update); }
//! fixed-rate bond /*! \ingroup instruments * * \test calculations are tested by checking results against * cached values. */ //! simple annual compounding coupon rates public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule, List <double> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, double redemption = 100, Date issueDate = null, Calendar paymentCalendar = null, Period exCouponPeriod = null, Calendar exCouponCalendar = null, BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted, bool exCouponEndOfMonth = false) : base(settlementDays, paymentCalendar ?? schedule.calendar(), issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, accrualDayCounter) .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth) .withPaymentCalendar(calendar_) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List <double>() { redemption }); Utils.QL_REQUIRE(cashflows().Count != 0, () => "bond with no cashflows!"); Utils.QL_REQUIRE(redemptions_.Count == 1, () => "multiple redemptions created"); }
protected ConvertibleBond(Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle <Quote> creditSpread, Date issueDate, int settlementDays, Schedule schedule, double redemption) : base(settlementDays, schedule.calendar(), issueDate) { conversionRatio_ = conversionRatio; callability_ = callability; dividends_ = dividends; creditSpread_ = creditSpread; maturityDate_ = schedule.endDate(); if (!callability.empty()) { Utils.QL_REQUIRE(callability.Last().date() <= maturityDate_, () => "last callability date (" + callability.Last().date() + ") later than maturity (" + maturityDate_.ToShortDateString() + ")"); } creditSpread.registerWith(update); }
//! fixed-rate bond /*! \ingroup instruments \test calculations are tested by checking results against cached values. */ //! simple annual compounding coupon rates public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,List<double> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, double redemption = 100, Date issueDate = null,Calendar paymentCalendar = null, Period exCouponPeriod = null, Calendar exCouponCalendar = null, BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted, bool exCouponEndOfMonth = false) : base(settlementDays, paymentCalendar == null ? schedule.calendar() : paymentCalendar, issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, accrualDayCounter) .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth) .withPaymentCalendar(calendar_) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List<double>() { redemption }); if (cashflows().Count == 0) throw new ApplicationException("bond with no cashflows!"); if (redemptions_.Count != 1) throw new ApplicationException("multiple redemptions created"); }
public CPIBond(int settlementDays, double faceAmount, bool growthOnly, double baseCPI, Period observationLag, ZeroInflationIndex cpiIndex, InterpolationType observationInterpolation, Schedule schedule, List <double> fixedRate, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.ModifiedFollowing, Date issueDate = null, Calendar paymentCalendar = null, Period exCouponPeriod = null, Calendar exCouponCalendar = null, BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted, bool exCouponEndOfMonth = false) : base(settlementDays, paymentCalendar ?? schedule.calendar(), issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; growthOnly_ = growthOnly; baseCPI_ = baseCPI; observationLag_ = observationLag; cpiIndex_ = cpiIndex; observationInterpolation_ = observationInterpolation; maturityDate_ = schedule.endDate(); // a CPIleg know about zero legs and inclusion of base inflation notional cashflows_ = new CPILeg(schedule, cpiIndex_, baseCPI_, observationLag_) .withSubtractInflationNominal(growthOnly_) .withObservationInterpolation(observationInterpolation_) .withPaymentDayCounter(accrualDayCounter) .withFixedRates(fixedRate) .withPaymentCalendar(calendar_) .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); calculateNotionalsFromCashflows(); cpiIndex_.registerWith(update); foreach (CashFlow i in cashflows_) { i.registerWith(update); } }
public CPIBond(int settlementDays, double faceAmount, bool growthOnly, double baseCPI, Period observationLag, ZeroInflationIndex cpiIndex, InterpolationType observationInterpolation, Schedule schedule, List<double> fixedRate, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.ModifiedFollowing, Date issueDate = null, Calendar paymentCalendar = null, Period exCouponPeriod = null, Calendar exCouponCalendar = null, BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted, bool exCouponEndOfMonth = false) :base(settlementDays, paymentCalendar == null ? schedule.calendar() : paymentCalendar, issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; growthOnly_ = growthOnly; baseCPI_=baseCPI; observationLag_ = observationLag; cpiIndex_= cpiIndex; observationInterpolation_ = observationInterpolation; maturityDate_ = schedule.endDate(); // a CPIleg know about zero legs and inclusion of base inflation notional cashflows_ = new CPILeg(schedule, cpiIndex_, baseCPI_, observationLag_) .withSubtractInflationNominal(growthOnly_) .withObservationInterpolation(observationInterpolation_) .withPaymentDayCounter(accrualDayCounter) .withFixedRates(fixedRate) .withPaymentCalendar(calendar_) .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); calculateNotionalsFromCashflows(); cpiIndex_.registerWith(update); foreach ( CashFlow i in cashflows_) i.registerWith(update); }
private List <Date> getListOfPeriodDatesIncludingQuasiPayments(Schedule schedule) { // Process the schedule into an array of dates. Date issueDate = schedule.date(0); Date firstCoupon = schedule.date(1); Date notionalFirstCoupon = schedule.calendar().advance(firstCoupon, -schedule.tenor(), schedule.businessDayConvention(), schedule.endOfMonth()); List <Date> newDates = schedule.dates().ToList(); newDates[0] = notionalFirstCoupon; // The handling of the last coupon is is needed for odd final periods var notionalLastCoupon = schedule.calendar().advance( schedule.date(schedule.Count - 2), schedule.tenor(), schedule.businessDayConvention(), schedule.endOfMonth()); newDates[schedule.Count - 1] = notionalLastCoupon; //long first coupon if (notionalFirstCoupon > issueDate) { Date priorNotionalCoupon = schedule.calendar().advance(notionalFirstCoupon, -schedule.tenor(), schedule.businessDayConvention(), schedule.endOfMonth()); newDates.Insert(0, priorNotionalCoupon); } // long last coupon if (notionalLastCoupon < schedule.endDate()) { Date nextNotionalCoupon = schedule.calendar().advance( notionalLastCoupon, schedule.tenor(), schedule.businessDayConvention(), schedule.endOfMonth()); newDates.Add(nextNotionalCoupon); } return(newDates); }
public AmortizingFloatingRateBond(int settlementDays, List<double> notionals, Schedule schedule, IborIndex index, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, int fixingDays = 0, List<double> gearings = null, List<double> spreads = null, List<double> caps = null, List<double> floors = null, bool inArrears = false, Date issueDate = null) :base(settlementDays, schedule.calendar(), issueDate) { if ( gearings == null ) gearings = new List<double>() {1, 1.0}; if (spreads == null) spreads = new List<double>() { 1, 0.0 }; if (caps == null) caps = new List<double>() ; if (floors == null) floors = new List<double>(); maturityDate_ = schedule.endDate(); cashflows_ = new IborLeg(schedule, index) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withSpreads(spreads) .withGearings(gearings) .withFixingDays(fixingDays) .withPaymentDayCounter(accrualDayCounter) .withPaymentAdjustment(paymentConvention) .withNotionals(notionals).value(); addRedemptionsToCashflows(); Utils.QL_REQUIRE( !cashflows().empty(), () => "bond with no cashflows!" ); index.registerWith(update); }
public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule, List <InterestRate> coupons, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, double redemption = 100, Date issueDate = null, Calendar paymentCalendar = null, Period exCouponPeriod = null, Calendar exCouponCalendar = null, BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted, bool exCouponEndOfMonth = false) : base(settlementDays, paymentCalendar == null ? schedule.calendar() : paymentCalendar, issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = coupons[0].dayCounter(); maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons) .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth) .withPaymentCalendar(calendar_) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List <double>() { redemption }); if (cashflows().Count == 0) { throw new ApplicationException("bond with no cashflows!"); } if (redemptions_.Count != 1) { throw new ApplicationException("multiple redemptions created"); } }
public CmsRateBond(int settlementDays, double faceAmount, Schedule schedule, SwapIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, int fixingDays = 0, List<double> gearings = null, List<double> spreads = null, List<double> caps = null, List<double> floors = null, bool inArrears = false, double redemption = 100.0, Date issueDate = null) : base(settlementDays, schedule.calendar(), issueDate) { // Optional value check if ( gearings == null ) gearings = new List<double>(){1}; if ( spreads == null ) spreads = new List<double>(){0}; if (caps == null) caps = new List<double>(); if (floors == null) floors = new List<double>(); maturityDate_ = schedule.endDate(); cashflows_ = new CmsLeg(schedule, index) .withPaymentDayCounter(paymentDayCounter) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List<double>() { redemption }); if (cashflows().Count == 0) throw new ApplicationException("bond with no cashflows!"); if (redemptions_.Count != 1) throw new ApplicationException("multiple redemptions created"); index.registerWith(update); }
public RangeAccrualFloatersCoupon(Date paymentDate, double nominal, IborIndex index, Date startDate, Date endDate, int fixingDays, DayCounter dayCounter, double gearing, double spread, Date refPeriodStart, Date refPeriodEnd, Schedule observationsSchedule, double lowerTrigger, double upperTrigger) : base(paymentDate, nominal, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter) { observationsSchedule_ = observationsSchedule; lowerTrigger_ = lowerTrigger; upperTrigger_ = upperTrigger; Utils.QL_REQUIRE(lowerTrigger_ < upperTrigger, () => "lowerTrigger_>=upperTrigger"); Utils.QL_REQUIRE(observationsSchedule_.startDate() == startDate, () => "incompatible start date"); Utils.QL_REQUIRE(observationsSchedule_.endDate() == endDate, () => "incompatible end date"); observationDates_ = new List <Date>(observationsSchedule_.dates()); observationDates_.RemoveAt(observationDates_.Count - 1); //remove end date observationDates_.RemoveAt(0); //remove start date observationsNo_ = observationDates_.Count; Handle <YieldTermStructure> rateCurve = index.forwardingTermStructure(); Date referenceDate = rateCurve.link.referenceDate(); startTime_ = dayCounter.yearFraction(referenceDate, startDate); endTime_ = dayCounter.yearFraction(referenceDate, endDate); observationTimes_ = new List <double>(); for (int i = 0; i < observationsNo_; i++) { observationTimes_.Add(dayCounter.yearFraction(referenceDate, observationDates_[i])); } }
public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule, List <InterestRate> coupons, BusinessDayConvention paymentConvention, double redemption, Date issueDate, Calendar paymentCalendar) : base(settlementDays, paymentCalendar == new Calendar() ? schedule.calendar() : paymentCalendar, issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = coupons[0].dayCounter(); maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons) .withPaymentCalendar(calendar_) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List <double>() { redemption }); if (cashflows().Count == 0) { throw new ApplicationException("bond with no cashflows!"); } if (redemptions_.Count != 1) { throw new ApplicationException("multiple redemptions created"); } }
public FloatingCatBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex iborIndex, DayCounter paymentDayCounter, NotionalRisk notionalRisk, BusinessDayConvention paymentConvention = QLNet.BusinessDayConvention.Following, int fixingDays = 0, List <double> gearings = null, List <double> spreads = null, List <double?> caps = null, List <double?> floors = null, bool inArrears = false, double redemption = 100.0, Date issueDate = null) : base(settlementDays, schedule.calendar(), issueDate, notionalRisk) { maturityDate_ = schedule.endDate(); cashflows_ = new IborLeg(schedule, iborIndex) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withPaymentDayCounter(paymentDayCounter) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new InitializedList <double>(1, redemption)); Utils.QL_REQUIRE(!cashflows().empty(), () => "bond with no cashflows!"); Utils.QL_REQUIRE(redemptions_.Count == 1, () => "multiple redemptions created"); iborIndex.registerWith(update); }
//! simple annual compounding coupon rates public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,List<double> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention, double redemption, Date issueDate,Calendar paymentCalendar) : base(settlementDays, paymentCalendar == new Calendar() ? schedule.calendar() : paymentCalendar, issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, accrualDayCounter) .withPaymentCalendar(calendar_) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List<double>() { redemption }); if (cashflows().Count == 0) throw new ApplicationException("bond with no cashflows!"); if (redemptions_.Count != 1) throw new ApplicationException("multiple redemptions created"); }
public CmsRateBond(int settlementDays, double faceAmount, Schedule schedule, SwapIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, int fixingDays = 0, List <double> gearings = null, List <double> spreads = null, List <double?> caps = null, List <double?> floors = null, bool inArrears = false, double redemption = 100.0, Date issueDate = null) : base(settlementDays, schedule.calendar(), issueDate) { // Optional value check if (gearings == null) { gearings = new List <double>() { 1 } } ; if (spreads == null) { spreads = new List <double>() { 0 } } ; if (caps == null) { caps = new List <double?>(); } if (floors == null) { floors = new List <double?>(); } maturityDate_ = schedule.endDate(); cashflows_ = new CmsLeg(schedule, index) .withPaymentDayCounter(paymentDayCounter) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List <double>() { redemption }); Utils.QL_REQUIRE(cashflows().Count != 0, () => "bond with no cashflows!"); Utils.QL_REQUIRE(redemptions_.Count == 1, () => "multiple redemptions created"); index.registerWith(update); } } }
public AmortizingFloatingRateBond(int settlementDays, List <double> notionals, Schedule schedule, IborIndex index, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, int fixingDays = 0, List <double> gearings = null, List <double> spreads = null, List <double> caps = null, List <double> floors = null, bool inArrears = false, Date issueDate = null) : base(settlementDays, schedule.calendar(), issueDate) { if (gearings == null) { gearings = new List <double>() { 1, 1.0 } } ; if (spreads == null) { spreads = new List <double>() { 1, 0.0 } } ; if (caps == null) { caps = new List <double>(); } if (floors == null) { floors = new List <double>(); } maturityDate_ = schedule.endDate(); cashflows_ = new IborLeg(schedule, index) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withSpreads(spreads) .withGearings(gearings) .withFixingDays(fixingDays) .withPaymentDayCounter(accrualDayCounter) .withPaymentAdjustment(paymentConvention) .withNotionals(notionals).value(); addRedemptionsToCashflows(); Utils.QL_REQUIRE(!cashflows().empty(), "bond with no cashflows!"); index.registerWith(update); } } }