/// <summary> /// /// </summary> /// <param name="baseDate"></param> /// <param name="bondAsset"></param> /// <param name="notionalAmount"></param> /// <param name="bondCouponType"></param> /// <param name="paymentConvention"></param> /// <param name="fOCalculationMethod"></param> /// <param name="fixingCalendar"></param> /// <param name="paymentCalendar"></param> /// <returns></returns> public static List <PriceableRateCoupon> CreatePriceableBondCoupons(DateTime baseDate, Bond bondAsset, decimal notionalAmount, CouponStreamType bondCouponType, BusinessDayAdjustments paymentConvention, bool fOCalculationMethod, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar) { List <PriceableRateCoupon> result = new List <PriceableRateCoupon>(); //This handles the case of a bond forward used in curve building. if (bondAsset.maturity > baseDate) { var rollConvention = RollConventionEnumHelper.Parse(bondAsset.maturity.Day.ToString(CultureInfo.InvariantCulture)); //var frequency = FrequencyHelper.ToFrequency(bondAsset.paymentFrequency); var unAdjustedPeriodDates = DateScheduler.GetUnadjustedCouponDatesFromMaturityDate(baseDate, bondAsset.maturity, bondAsset.paymentFrequency, rollConvention, out _, out _); var adjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unAdjustedPeriodDates, paymentConvention.businessDayConvention, paymentCalendar).ToArray(); var length = unAdjustedPeriodDates.Length; for (int i = 0; i < length - 1; i++) { var id = "Coupon" + "_" + i; var startDate = unAdjustedPeriodDates[i]; var endDate = unAdjustedPeriodDates[i + 1]; var paymentDate = adjustedPeriodDates[i + 1]; var coupon = CreatePriceableBondCoupon(id, bondAsset, notionalAmount, bondCouponType, startDate, endDate, paymentDate, paymentCalendar); result.Add(coupon); } return(result); } return(result); }
/// <summary> /// Adjusteds the dates from effective date. /// </summary> /// <param name="effectiveDate">The effective date.</param> /// <param name="terminationDate">The termination date.</param> /// <param name="periodInterval">The period interval.</param> /// <param name="rollConvention">The roll convention.</param> /// <param name="businessCenters">The business centers.</param> /// <param name="dateAdjustmentConvention">The date adjustment convention.</param> /// <returns>A vertical arrray of dates.</returns> public object[,] AdjustedDatesFromEffectiveDate(DateTime effectiveDate, DateTime terminationDate, string periodInterval, string rollConvention, string businessCenters, string dateAdjustmentConvention) { BusinessCenters centers = BusinessCentersHelper.Parse(businessCenters); IBusinessCalendar calendar = Engine.ToBusinessCalendar(centers); var adjustments = EnumHelper.Parse <BusinessDayConventionEnum>(dateAdjustmentConvention); var adjustedDateSchedule = AdjustedDateScheduler.AdjustedDatesFromEffectiveDate(effectiveDate, terminationDate, periodInterval, rollConvention, calendar, adjustments); var result = RangeHelper.ConvertArrayToRange(adjustedDateSchedule); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableIRSwap"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="nodeStruct">The nodeStruct;</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> /// <param name="fixedRate">The fixed rate.</param> public PriceableIRSwap(DateTime baseDate, SimpleIRSwapNodeStruct nodeStruct, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate) : base(baseDate, nodeStruct, fixingCalendar, paymentCalendar, fixedRate) { ModelIdentifier = DiscountingType == null ? "SwapAsset" : "DiscountSwapAsset"; //The floating leg which is now non-zero. var unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleIRSwap.term, UnderlyingRateIndex.term); FloatingLegAdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, BusinessDayAdjustments.businessDayConvention, fixingCalendar); FloatingLegWeightings = CreateWeightings(CDefaultWeightingValue, FloatingLegAdjustedPeriodDates.Count - 1); FloatingLegYearFractions = GetFloatingLegYearFractions(); }
/// <summary> /// Gets the adjusted calculation period start dates. /// </summary> /// <param name="effectiveDate">The effective date.</param> /// <param name="terminationDate">The termination date.</param> /// <param name="periodInterval">The period interval.</param> /// <param name="rollConvention">The roll convention.</param> /// <param name="firstRegularPeriodDate">The first regular period date.</param> /// <param name="stubPeriodType">Type of the stub period.</param> /// <param name="calendars">The holiday array.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <returns>A vertival range of dates.</returns> public object[,] GetAdjustedCalculationPeriodDates(DateTime effectiveDate, DateTime terminationDate, string periodInterval, string rollConvention, DateTime firstRegularPeriodDate, string stubPeriodType, Excel.Range calendars, string businessDayConvention) { List <string> unqVals = DataRangeHelper.StripRange(calendars); IBusinessCalendar businessCalendar = CalendarService.GetCalendar(unqVals.ToArray()); var dates = AdjustedDateScheduler.GetAdjustedCalculationPeriodDates(effectiveDate, terminationDate, periodInterval, rollConvention, firstRegularPeriodDate, stubPeriodType, businessCalendar, businessDayConvention); var result = RangeHelper.ConvertArrayToRange(dates); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableSimpleIRCap"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="interestRateCap">An interest Rate Cap.</param> /// <param name="properties">THe properies, including strike information.</param> /// <param name="fixingCalendar">The fixing Calendar.</param> /// <param name="paymentCalendar">The payment Calendar.</param> /// <param name="marketQuotes">The market Quote: premium, normal flat volatility or lognormal flat volatility.</param> public PriceableSimpleIRCap(DateTime baseDate, SimpleIRCapNodeStruct interestRateCap, NamedValueSet properties, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicAssetValuation marketQuotes) : base(baseDate, interestRateCap.DateAdjustments, ReversePeriodMultiplier(interestRateCap.SpotDate), interestRateCap.Calculation, marketQuotes) { Id = interestRateCap.SimpleIRCap.id; IsCap = true; SimpleIRCap = interestRateCap.SimpleIRCap; var spotDate = GetSpotDate(baseDate, fixingCalendar, interestRateCap.SpotDate); if (SimpleIRCap != null) { var unadjustedDates = Analytics.Schedulers.DateScheduler.GetUnadjustedDateSchedule(spotDate, SimpleIRCap.term, SimpleIRCap.paymentFrequency); AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDates, PaymentBusinessDayAdjustments.businessDayConvention, paymentCalendar); //Adjust for the spot period backwards! ExpiryDates = AdjustedDateScheduler.GetAdjustedDateSchedule(AdjustedPeriodDates, FixingBusinessDayOffset, fixingCalendar); //Remove the last date, which is not an expiry date. ExpiryDates.RemoveAt(ExpiryDates.Count - 1); TimesToExpiry = GetTimesToExpiry(ExpiryDates, baseDate); //Set the strike scalar. This must be after the number of expiry dates has been set. var quotes = new List <BasicQuotation>(marketQuotes.quote); //For the default cap the spot rate is used. SetQuote("SpotRate", quotes); //If the strike is not provided it must be calculated!! SetQuote("Strike", quotes); //Set the spot date. AdjustedStartDate = AdjustedPeriodDates[0]; RiskMaturityDate = ExpiryDates[ExpiryDates.Count - 1]; OptionsExpiryDate = ExpiryDates[ExpiryDates.Count - 1]; if (Strike != null && Strikes == null) { Strikes = CreateList((decimal)Strike, TimesToExpiry.Count); } if (Notionals == null) { Notionals = CreateList(InitialNotional, TimesToExpiry.Count); } } if (ExpiryDates[0] <= BaseDate) { IncludeFirstPeriod = false; } if (DiscountingType != null) { ModelIdentifier = "DiscountCapAsset"; } }
/// <summary> /// Initializes a new instance of the <see cref="PriceableSimpleFra"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="nodeStruct"></param> /// <param name="fixingCalendar"></param> /// <param name="paymentCalendar"></param> /// <param name="fixedRate">The fixed rate.</param> public PriceableSimpleRevenueInflationSwap(DateTime baseDate, SimpleIRSwapNodeStruct nodeStruct, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate) : base(baseDate, nodeStruct.DateAdjustments, fixedRate) { Id = nodeStruct.SimpleIRSwap.id; SimpleInflationSwap = nodeStruct.SimpleIRSwap; SpotDateOffset = nodeStruct.SpotDate; Calculation = nodeStruct.Calculation; UnderlyingRateIndex = nodeStruct.UnderlyingRateIndex; AdjustedStartDate = GetSpotDate(baseDate, fixingCalendar, SpotDateOffset); DayCounter = DayCounterHelper.Parse(Calculation.dayCountFraction.Value); List <DateTime> unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleInflationSwap.term, SimpleInflationSwap.paymentFrequency); AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, nodeStruct.DateAdjustments.businessDayConvention, paymentCalendar); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableIRSwap"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="fixedLegSwap">The fixed leg details.</param> /// <param name="spotDate">the spot date.</param> /// <param name="notional">The notional amount.</param> /// <param name="paymentBusinessDayAdjustments">The business day adjustments.</param> /// <param name="floatingLegSwap">The floating leg details.</param> /// <param name="floatingLegcalculation">The floatingLegcalculation.</param> /// <param name="fixingDateOffset">The fixing date business day adjustments.</param> /// <param name="resetRates">The reset rates of the floating leg - if any.</param> /// <param name="fixingCalendar">The fixing calendar. If null, a new is constructed based on the business calendars.</param> /// <param name="paymentCalendar">The payment calendar. If null, a new is constructed based on the business calendars.</param> /// <param name="fixedRate">The fixed rate.</param> /// <param name="spread">The spread on the floating leg.</param> public PriceableIRSwap(DateTime baseDate, SimpleIRSwap fixedLegSwap, DateTime spotDate, MoneyBase notional, BusinessDayAdjustments paymentBusinessDayAdjustments, SimpleIRSwap floatingLegSwap, Calculation floatingLegcalculation, RelativeDateOffset fixingDateOffset, List <Decimal> resetRates, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate, BasicQuotation spread) : base(baseDate, fixedLegSwap, fixingDateOffset, floatingLegcalculation, paymentBusinessDayAdjustments, null, fixingCalendar, paymentCalendar, fixedRate) { ModelIdentifier = DiscountingType == null ? "SwapAsset" : "DiscountSwapAsset"; FloatingLegSpread = GetSpread(spread); ForwardRates = resetRates?.ToArray(); UnderlyingRateIndex = RateIndexHelper.Parse(FloatingRateCalculation.floatingRateIndex.Value, notional.currency.Value, Calculation.dayCountFraction.Value); var unadjustedFloatingDates = DateScheduler.GetUnadjustedDateSchedule(spotDate, floatingLegSwap.term, floatingLegSwap.paymentFrequency); FloatingLegAdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedFloatingDates, paymentBusinessDayAdjustments.businessDayConvention, paymentCalendar); FloatingLegWeightings = CreateWeightings(CDefaultWeightingValue, FloatingLegAdjustedPeriodDates.Count - 1); FloatingLegYearFractions = GetFloatingLegYearFractions(); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableLeaseAsset"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="paymentCalendar">The payment Calendar.</param> /// <param name="marketQuote">The market quote.</param> /// <param name="lease">The lease.</param> public PriceableLeaseAsset(DateTime baseDate, FpML.V5r3.Reporting.Lease lease, IBusinessCalendar paymentCalendar, BasicQuotation marketQuote) { PaymentCalendar = paymentCalendar; Multiplier = 1.0m; YearFractions = new[] { 0.25m }; ModelIdentifier = "LeaseAsset"; StartAmount = lease.startGrossPrice.amount; MaturityDate = lease.leaseExpiryDate.Value; Frequency = lease.paymentFrequency; LeaseRate = lease.reviewChange; Currency = lease.currency; BaseDate = baseDate; SettlementDate = baseDate; PaymentBusinessDayAdjustments = lease.businessDayAdjustments; FirstPaymentDate = lease.startDate.Value; ReviewFrequency = lease.reviewFrequency; NextReviewDate = lease.nextReviewDate.Value; if (MaturityDate > BaseDate) { var rollConvention = RollConventionEnumHelper.Parse(MaturityDate.Day.ToString(CultureInfo.InvariantCulture)); UnAdjustedPeriodDates = DateScheduler.GetUnadjustedCouponDatesFromMaturityDate(SettlementDate, MaturityDate, Frequency, rollConvention, out _, out var nextCouponDate); LastPaymentDate = UnAdjustedPeriodDates[0]; AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(UnAdjustedPeriodDates, PaymentBusinessDayAdjustments.businessDayConvention, paymentCalendar).ToArray(); AdjustedPeriodDates[0] = SettlementDate; NextPaymentDate = nextCouponDate; } RiskMaturityDate = AdjustedPeriodDates[AdjustedPeriodDates.Length - 1]; Weightings = CreateWeightings(CDefaultWeightingValue, AdjustedPeriodDates.Length - 1);//, LeaseRate, //TODO Need to add a credit spread to this. LeaseDiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="simpleIRSwap">THe FpML swap.</param> /// <param name="spotDate">The spot date.</param> /// <param name="calculation">A calculation.</param> /// <param name="stringRollConvention">The roll convention.</param> /// <param name="businessDayAdjustments">The business day adjustments.</param> /// <param name="underlyingRateIndex">Index of the rate.</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> /// <param name="fixedRate">The fixed rate.</param> public PriceableSimpleIRSwap(DateTime baseDate, SimpleIRSwap simpleIRSwap, DateTime spotDate, Calculation calculation, String stringRollConvention, BusinessDayAdjustments businessDayAdjustments, RateIndex underlyingRateIndex, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate) : base(baseDate, businessDayAdjustments, calculation, fixedRate) { Id = simpleIRSwap.id; SimpleIRSwap = simpleIRSwap; UnderlyingRateIndex = underlyingRateIndex; AdjustedStartDate = spotDate; List <DateTime> unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleIRSwap.term, SimpleIRSwap.paymentFrequency); AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, BusinessDayAdjustments.businessDayConvention, paymentCalendar); RiskMaturityDate = AdjustedPeriodDates[AdjustedPeriodDates.Count - 1]; Weightings = CreateWeightings(CDefaultWeightingValue, AdjustedPeriodDates.Count - 1); YearFractions = GetYearFractions(); ModelIdentifier = DiscountingType == null ? "SimpleSwapAsset" : "SimpleDiscountSwapAsset"; var timeToMaturity = Actual365.Instance.YearFraction(baseDate, RiskMaturityDate); EndDiscountFactor = (decimal)System.Math.Exp(-(double)fixedRate.value * timeToMaturity); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="nodeStruct">The nodeStruct;</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> /// <param name="fixedRate">The fixed rate.</param> public PriceableSimpleIRSwap(DateTime baseDate, SimpleIRSwapNodeStruct nodeStruct, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate) : base(baseDate, nodeStruct.DateAdjustments, nodeStruct.Calculation, fixedRate) { Id = nodeStruct.SimpleIRSwap.id; FixingDateOffset = nodeStruct.SpotDate; SimpleIRSwap = nodeStruct.SimpleIRSwap; UnderlyingRateIndex = nodeStruct.UnderlyingRateIndex; //TODO: This needs to be modified to use backwards roll. AdjustedStartDate = GetSpotDate(baseDate, fixingCalendar, FixingDateOffset); List <DateTime> unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleIRSwap.term, SimpleIRSwap.paymentFrequency); AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, BusinessDayAdjustments.businessDayConvention, paymentCalendar); RiskMaturityDate = AdjustedPeriodDates[AdjustedPeriodDates.Count - 1]; Weightings = CreateWeightings(CDefaultWeightingValue, AdjustedPeriodDates.Count - 1); YearFractions = GetYearFractions(); ModelIdentifier = DiscountingType == null ? "SimpleSwapAsset" : "SimpleDiscountSwapAsset"; var timeToMaturity = Actual365.Instance.YearFraction(baseDate, RiskMaturityDate); EndDiscountFactor = (decimal)System.Math.Exp(-(double)fixedRate.value * timeToMaturity); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableIRCap"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="effectiveDate">The effective Date.</param> /// <param name="term">The cap term.</param> /// <param name="strike">The strike for each caplet.</param> /// <param name="lastResets">A list of reset rates. This may be null.</param> /// <param name="includeStubFlag">A flag: include the first stub period or not.</param> /// <param name="paymentFrequency">The caplet frequency.</param> /// <param name="rollBackward">A flag which determines whether to roll /// the dates: Backward or Forward. Currency this is ignored.</param> /// <param name="resetOffset">The relative date offset for all the fixings.</param> /// <param name="paymentBusinessDayAdjustments">The payment business day adjustments.</param> /// <param name="fixingCalendar">The fixing Calendar.</param> /// <param name="paymentCalendar">The payment Calendar.</param> /// <param name="capCalculation">The cap calculation.</param> public PriceableIRCap(DateTime baseDate, DateTime effectiveDate, string term, Double strike, List <double> lastResets, Boolean includeStubFlag, string paymentFrequency, Boolean rollBackward, RelativeDateOffset resetOffset, BusinessDayAdjustments paymentBusinessDayAdjustments, Calculation capCalculation, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar) : base(baseDate, paymentBusinessDayAdjustments, resetOffset, capCalculation, null) { Id = "Local"; SimpleIRCap = new SimpleIRSwap { dayCountFraction = capCalculation.dayCountFraction }; ResetRates = lastResets; var unadjustedDates = Analytics.Schedulers.DateScheduler.GetUnadjustedDateSchedule(effectiveDate, PeriodHelper.Parse(term), PeriodHelper.Parse(paymentFrequency)); var adjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDates, paymentBusinessDayAdjustments.businessDayConvention, paymentCalendar); RiskMaturityDate = adjustedPeriodDates[adjustedPeriodDates.Count - 1]; IncludeFirstPeriod = includeStubFlag; //if (!includeStubFlag) //{ // adjustedPeriodDates.RemoveAt(0); //} AdjustedStartDate = effectiveDate; AdjustedPeriodDates = adjustedPeriodDates; ExpiryDates = GetResetDates(AdjustedPeriodDates, fixingCalendar, resetOffset, true); OptionsExpiryDate = ExpiryDates[ExpiryDates.Count - 1]; IsCap = true; YearFractions = GetYearFractions(); Strikes = CreateList(strike, YearFractions.Count); Notionals = CreateList((double)InitialNotional, YearFractions.Count); if (DiscountingType != null) { ModelIdentifier = "DiscountCapAsset"; } }
/// <summary> /// Initializes a new instance of the <see cref="PriceableSimpleBond"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="bond">The bond</param> /// <param name="settlementDate">The settlement date.</param> /// <param name="exDivDate">The ex dividend date.</param> /// <param name="businessDayAdjustments">The business day adjustments.</param> /// <param name="paymentCalendar">The payment Calendar.</param> /// <param name="marketQuote">The market quote.</param> /// <param name="quoteType">The quote type</param> public PriceableSimpleBond(DateTime baseDate, Bond bond, DateTime settlementDate, DateTime exDivDate, BusinessDayAdjustments businessDayAdjustments, IBusinessCalendar paymentCalendar, BasicQuotation marketQuote, BondPriceEnum quoteType) : base(baseDate, bond.faceAmount, bond.currency, null, null, businessDayAdjustments, marketQuote, quoteType) { Id = bond.id; var tempId = Id.Split('-'); var bondId = tempId[0]; if (tempId.Length > 2) { bondId = tempId[2]; } Issuer = (string)bond.Item;//Does not handle PartyReference type -> only string! Description = "Not Defined"; if (bond.description != null) { Description = bond.description; } MaturityDate = bond.maturity; CouponDayCount = new DayCountFraction { Value = bond.dayCountFraction.Value }; if (bond.parValueSpecified) { ParValue = bond.parValue; } if (bond.couponRateSpecified) { CouponRate = bond.couponRate; } CouponFrequency = new Period { period = bond.paymentFrequency.period, periodMultiplier = bond.paymentFrequency.periodMultiplier }; CouponType = CouponTypeEnum.Fixed; if (bond.clearanceSystem != null) { ClearanceSystem = bond.clearanceSystem.Value; } if (bond.exchangeId != null) { Exchange = bond.exchangeId.Value; } if (bond.seniority != null) { Seniority = EnumHelper.Parse <CreditSeniorityEnum>(bond.seniority.Value); } if (bond.instrumentId != null) { InstrumentIds = new List <InstrumentId>(); foreach (var identifier in bond.instrumentId.Select(id => InstrumentIdHelper.Parse(id.Value))) { InstrumentIds.Add(identifier); } } //This handles the case of a bond forward used in curve building. if (MaturityDate > BaseDate) { var rollConvention = RollConventionEnumHelper.Parse(MaturityDate.Day.ToString(CultureInfo.InvariantCulture)); Frequency = FrequencyHelper.ToFrequency(bond.paymentFrequency); SettlementDate = settlementDate; UnAdjustedPeriodDates = DateScheduler.GetUnadjustedCouponDatesFromMaturityDate(SettlementDate, MaturityDate, CouponFrequency, rollConvention, out _, out var nextCouponDate); LastCouponDate = UnAdjustedPeriodDates[0]; NextCouponDate = nextCouponDate; AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(UnAdjustedPeriodDates, PaymentBusinessDayAdjustments.businessDayConvention, paymentCalendar).ToArray(); AdjustedPeriodDates[0] = SettlementDate; NextExDivDate = exDivDate; IsXD = IsExDiv(); } BondCurveName = CurveNameHelpers.GetBondCurveName(Currency.Value, bondId); SwapDiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableSimpleBond"/> class. /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="nodeStruct">The bond nodeStruct</param> /// <param name="settlementCalendar">The settlement Calendar.</param> /// <param name="paymentCalendar">The payment Calendar.</param> /// <param name="marketQuote">The market quote.</param> /// <param name="quoteType">THe quote Type</param> public PriceableSimpleBond(DateTime baseDate, BondNodeStruct nodeStruct, IBusinessCalendar settlementCalendar, IBusinessCalendar paymentCalendar, BasicQuotation marketQuote, BondPriceEnum quoteType) : base(baseDate, nodeStruct.Bond.faceAmount, nodeStruct.Bond.currency, nodeStruct.SettlementDate, nodeStruct.ExDivDate, nodeStruct.BusinessDayAdjustments, marketQuote, quoteType) { Id = nodeStruct.Bond.id; var tempId = Id.Split('-'); var bondId = tempId[0]; if (tempId.Length > 2) { bondId = tempId[2]; } SettlementDateCalendar = settlementCalendar; Issuer = (string)nodeStruct.Bond.Item;//Does not handle PartyReference type -> only string! Description = "Not Defined"; //IsYTMQuote = true; if (nodeStruct.Bond.description != null) { Description = nodeStruct.Bond.description; } MaturityDate = nodeStruct.Bond.maturity; CouponDayCount = new DayCountFraction { Value = nodeStruct.Bond.dayCountFraction.Value }; CouponFrequency = new Period { period = nodeStruct.Bond.paymentFrequency.period, periodMultiplier = nodeStruct.Bond.paymentFrequency.periodMultiplier }; if (nodeStruct.Bond.couponRateSpecified) { CouponRate = nodeStruct.Bond.couponRate; } if (nodeStruct.Bond.parValueSpecified) { ParValue = nodeStruct.Bond.parValue; } if (nodeStruct.Bond.clearanceSystem != null) { ClearanceSystem = nodeStruct.Bond.clearanceSystem.Value; } if (nodeStruct.Bond.exchangeId != null) { Exchange = nodeStruct.Bond.exchangeId.Value; } CouponType = CouponTypeEnum.Fixed; if (nodeStruct.Bond.seniority != null) { Seniority = EnumHelper.Parse <CreditSeniorityEnum>(nodeStruct.Bond.seniority.Value, true); } if (nodeStruct.Bond.instrumentId != null) { InstrumentIds = new List <InstrumentId>(); foreach (var identifier in nodeStruct.Bond.instrumentId.Select(id => InstrumentIdHelper.Parse(id.Value))) { InstrumentIds.Add(identifier); } } //This handles the case of a bondforward used in curve building. if (MaturityDate > BaseDate) { DateTime lastCouponDate; DateTime nextCouponDate; var rollConvention = RollConventionEnumHelper.Parse(MaturityDate.Day.ToString(CultureInfo.InvariantCulture)); Frequency = FrequencyHelper.ToFrequency(nodeStruct.Bond.paymentFrequency); //Get the settlement date SettlementDate = GetSettlementDate(baseDate, settlementCalendar, nodeStruct.SettlementDate); //Generate the necessary dates. //TODO Should the settlement date and the underlying bond be calculated on the fly when calculation occurs? UnAdjustedPeriodDates = DateScheduler.GetUnadjustedCouponDatesFromMaturityDate(SettlementDate, MaturityDate, CouponFrequency, rollConvention, out lastCouponDate, out nextCouponDate); LastCouponDate = UnAdjustedPeriodDates[0]; NextCouponDate = nextCouponDate; AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(UnAdjustedPeriodDates, nodeStruct.BusinessDayAdjustments .businessDayConvention, paymentCalendar) .ToArray(); AdjustedPeriodDates[0] = SettlementDate; //TODO check this! NextExDivDate = GetNextExDivDate(); IsXD = IsExDiv(); } BondCurveName = CurveNameHelpers.GetBondCurveName(Currency.Value, bondId); SwapDiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true); }