public static RelativeDateOffset Create(string period, DayTypeEnum dayType, string businessDayConventionAsString, BusinessCenters businessCenters, string dateRelativeTo) { var result = new RelativeDateOffset(); Period interval = PeriodHelper.Parse(period); result.period = interval.period; result.periodSpecified = true; result.periodMultiplier = interval.periodMultiplier; result.dayType = dayType; result.dayTypeSpecified = true; if (businessDayConventionAsString != null) { result.businessDayConvention = BusinessDayConventionHelper.Parse(businessDayConventionAsString); result.businessDayConventionSpecified = true; } result.businessCenters = businessCenters; if (dateRelativeTo != null) { var dateReference = new DateReference { href = dateRelativeTo }; result.dateRelativeTo = dateReference; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableRateCoupon"/> class. /// </summary> /// <param name="cashflowId">The stream id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustCalculationDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="fixedRate">The fixed rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountFraction">Type of day Count fraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fra discounting</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFixedRateCoupon ( string cashflowId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , bool adjustCalculationDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountFraction , decimal fixedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , DiscountingTypeEnum?discountingType , decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar paymentCalendar) : base(cashflowId, CouponType.FixedRate, payerIsBase, accrualStartDate, accrualEndDate, adjustCalculationDatesIndicator, accrualBusinessCenters, accrualRollConvention, dayCountFraction, fixedRate, notionalAmount, paymentDate, discountingType, discountRate, fraDiscounting, paymentCalendar) { Id = cashflowId; CalculatePaymentAmount(0); ForecastAmount = PaymentAmount; }
/// <summary> /// Initializes a new instance of the <see cref="PriceableFxRateCashflow"/> class. /// </summary> /// <param name="cashlfowId">The stream id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustAccrualDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="margin">The margin.</param> /// <param name="baseRate">The base rate for a nettable fixed/floating cash flow. </param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountfraction">Type of day Countfraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecastrateindex.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fradiscounting</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFloatingRateCoupon ( string cashlfowId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustAccrualDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountfraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal baseRate , Decimal?observedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base( cashlfowId , CouponType.FloatingRate , payerIsBase , accrualStartDate , accrualEndDate , adjustAccrualDatesIndicator , accrualBusinessCenters , accrualRollConvention , dayCountfraction , observedRate , notionalAmount , paymentDate , discountingType , discountRate , fraDiscounting , paymentCalendar) { BaseRate = baseRate; FixingCalendar = fixingCalendar; ModelIdentifier = "DualCurveCouponModel"; Id = cashlfowId; ForwardStartDate = AccrualStartDate; ForecastRateIndex = forecastRateIndex; FixingDateRelativeOffset = fixingDateRelativeOffset; ResetRelativeTo = resetRelativeTo; Margin = margin; AdjustedFixingDate = GetResetDate(resetRelativeTo, fixingDateRelativeOffset); if (observedRate != null) { RateObservation = RateObservationHelper.Parse(AdjustedFixingDate, (decimal)observedRate, "1"); } SetRateObservation(RateObservation, ResetDate); ForecastCurveName = CurveNameHelpers.GetForecastCurveName(forecastRateIndex); }
/// <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> /// A helper to extract properties from a namedvalueset.. /// </summary> /// <param name="propertyCollection">The collection of properties.</param> public static BusinessCenters ExtractBusinessCenters(NamedValueSet propertyCollection) { BusinessCenters businessCentres = null; var dictionaryKeys = propertyCollection.ToDictionary(); if (dictionaryKeys.ContainsKey("BusinessCenters")) { var centres = propertyCollection.Get("BusinessCenters").AsValue <string[]>(); businessCentres = BusinessCentersHelper.Parse(centres); } return(businessCentres); }
/// <summary> /// Creates a consolidated business calendar for a given set of business centers /// </summary> /// <param name="centers">The centers.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">The clients namespace</param> /// <returns></returns> public static IBusinessCalendar ToBusinessCalendar(ICoreCache cache, BusinessCenters centers, string nameSpace) { if (centers != null) { var calendars = centers.businessCenter.Select(businessCenter => businessCenter.Value).ToArray(); var dps = GetDateRuleParser(cache, calendars, nameSpace); var significantDays = GetBusinessCentreHolidayDates(cache, Dedupe(dps.FpmlName), nameSpace); IBusinessCalendar result = new BusinessCalendar(significantDays, dps); return(result); } return(null); }
public static BusinessCenters Parse(string[] businessCentersAsString) { var result = new BusinessCenters { businessCenter = businessCentersAsString.Select( businessCenterAsString => new BusinessCenter { Value = businessCenterAsString }).ToArray() }; return(result); }
/// <summary> /// Gets a dates schedule. /// </summary> /// <param name="metaScheduleDefinitionRange">This must have 3 columns: interval, interval, rollconventionenum.</param> /// <param name="startDate">The start date of the schedule to be generated.</param> /// <param name="calendar">The relevant calendar.</param> /// <param name="businessDayAdjustment">The business day adjustments.</param> /// <returns>A vertical arrray of dates.</returns> public object[,] GetMetaDatesSchedule(Excel.Range metaScheduleDefinitionRange, DateTime startDate, string calendar, string businessDayAdjustment) { var values = metaScheduleDefinitionRange.Value[System.Reflection.Missing.Value] as object[, ]; List <ThreeStringsRangeItem> metaScheduleDefinition = ObjectToArrayOfPropertiesConverter.CreateListFromHorizontalArrayRange <ThreeStringsRangeItem>(values); BusinessCenters centers = BusinessCentersHelper.Parse(calendar); IBusinessCalendar businessCalendar = Engine.ToBusinessCalendar(centers); var metaSchedule = AdjustedDatesMetaSchedule.GetMetaDatesSchedule(metaScheduleDefinition, startDate, businessCalendar, calendar, businessDayAdjustment); var result = RangeHelper.ConvertArrayToRange(metaSchedule); return(result); }
public static BusinessCenters Parse(string[] businessCentersAsString) { BusinessCenters result = new BusinessCenters(); List <BusinessCenter> list = new List <BusinessCenter>(); foreach (string businessCenterAsString in businessCentersAsString) { BusinessCenter businessCenter = new BusinessCenter(); businessCenter.Value = businessCenterAsString; list.Add(businessCenter); } result.businessCenter = list.ToArray(); return(result); }
public static BusinessCenters Parse(string businessCentersAsString) { var result = new BusinessCenters { businessCenter = businessCentersAsString.Split(BusinessCenterNameSeparatorCharacters) .Select( businessCenterAsString => new BusinessCenter { Value = businessCenterAsString }) .ToArray() }; return(result); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableFxRateCashflow"/> class. /// </summary> /// <param name="cashlfowId">The stream id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustAccrualDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="margin">The margin.</param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountfraction">Type of day Countfraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecastrateindex.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fradiscounting</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFloatingRateCoupon ( string cashlfowId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustAccrualDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountfraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal?observedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : this( cashlfowId , payerIsBase , accrualStartDate , accrualEndDate , adjustAccrualDatesIndicator , accrualBusinessCenters , accrualRollConvention , dayCountfraction , resetRelativeTo , fixingDateRelativeOffset , margin , 0.0m , observedRate , notionalAmount , paymentDate , forecastRateIndex , discountingType , discountRate , fraDiscounting , fixingCalendar , paymentCalendar) { }
/// <summary> /// Initializes a new instance of the <see cref="PriceableRateCoupon"/> class. /// </summary> /// <param name="cashlfowId">The stream id.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustCalculationDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="underlyingRateIndex">Te underlying rate index can be Xibor or Swap.</param> /// <param name="resetLagOffset">This allows for non-standard lags to be used in convexity adjustment calculations.</param> /// <param name="margin">The margin.</param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="accrualDayCountfraction">Type of day Countfraction used for the acrual period.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecastrateindex.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// <param name="underlyingRateIndex"></param> /// then it is assumed that there is no fradiscounting</param> public PriceableStructuredRateCoupon ( string cashlfowId , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustCalculationDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction accrualDayCountfraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , RateIndex underlyingRateIndex , RelativeDateOffset resetLagOffset , Decimal margin , Decimal?observedRate , Money notionalAmount , AdjustableDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting) : base( cashlfowId , accrualStartDate , accrualEndDate , adjustCalculationDatesIndicator , accrualBusinessCenters , accrualRollConvention , accrualDayCountfraction , resetRelativeTo , fixingDateRelativeOffset , margin , observedRate , notionalAmount , paymentDate , forecastRateIndex , discountingType , discountRate , fraDiscounting ) { UnderlyingRateIndex = underlyingRateIndex; ResetLagOffset = resetLagOffset; PriceableCouponType = CouponType.StructuredRate; AnalyticsModel = new StructuredRateCouponAnalytic(); }
public static void ResolveBusinessCenters(object objectGraph) { //BusinessDayAdjustments[] businessDayAdjustments = ; foreach (BusinessDayAdjustments businessDayAdjustment in GetBusinessDayAdjustments(objectGraph)) { // "NONE" adjustments have neither businessCenters nor businessCentersReference. // if ((null != businessDayAdjustment) && (null == businessDayAdjustment.businessCenters) && (null != businessDayAdjustment.businessCentersReference) && (!String.IsNullOrEmpty(businessDayAdjustment.businessCentersReference.href))) { BusinessCenters businessCenters = ObjectLookupHelper.GetById <BusinessCenters>(objectGraph, businessDayAdjustment.businessCentersReference.href); BusinessCenters businessCentersCloneWithNoId = BinarySerializerHelper.Clone <BusinessCenters>(businessCenters); businessCentersCloneWithNoId.id = null; businessDayAdjustment.businessCenters = businessCentersCloneWithNoId; } } }
public static BusinessDayAdjustments Create(BusinessDayConventionEnum businessDayConvention, BusinessCenters businessCenters) { var result = new BusinessDayAdjustments { businessDayConvention = businessDayConvention, businessCenters = businessCenters }; return(result); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableCapFloorCoupon"/> class. /// </summary> /// <param name="cashFlowId">The stream id.</param> /// <param name="buyerIsBase">The buyer is base flag.</param> /// <param name="capStrike">The Cap strike.</param> /// <param name="floorStrike">The floor strike.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustAccrualDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="margin">The margin.</param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountFraction">Type of day Count fraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecast rate index.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fra discounting</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableCapFloorCoupon ( string cashFlowId , bool buyerIsBase , decimal?capStrike , decimal?floorStrike , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustAccrualDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountFraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal?observedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base( cashFlowId , buyerIsBase , accrualStartDate , accrualEndDate , adjustAccrualDatesIndicator , accrualBusinessCenters , accrualRollConvention , dayCountFraction , resetRelativeTo , fixingDateRelativeOffset , margin , observedRate , notionalAmount , paymentDate , forecastRateIndex , discountingType , discountRate , fraDiscounting , fixingCalendar , paymentCalendar) { CapStrike = capStrike; FloorStrike = floorStrike; VolatilitySurfaceName = CurveNameHelpers.GetRateVolatilityMatrixName(forecastRateIndex); if (capStrike != null && floorStrike == null) { PriceableCouponType = CouponType.Cap; ModelIdentifier = "DualCurveCapModel"; IsCall = true; } if (floorStrike != null && capStrike == null) { PriceableCouponType = CouponType.Floor; ModelIdentifier = "DualCurveFloorModel"; } if (floorStrike != null && capStrike != null) { PriceableCouponType = CouponType.Collar; ModelIdentifier = "DualCurveCollarModel"; } }