/// <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="margin">The margin.</param>
 /// <param name="observedRate">The observed Rate. If this is not null, then it is used.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="adjustedFixingDate">The adjusted fixing date.</param>
 /// <param name="dayCountfraction">Type of day Countfraction.</param>
 /// <param name="paymentDate">The payment date.</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>
 public PriceableComplexRateCoupon
 (
     string cashlfowId
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , DateTime adjustedFixingDate
     , DayCountFraction dayCountfraction
     , Decimal margin
     , Decimal?observedRate
     , Money notionalAmount
     , DateTime paymentDate
     , ForecastRateIndex forecastRateIndex
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting)
     : base(
         cashlfowId
         , accrualStartDate
         , accrualEndDate
         , adjustedFixingDate
         , dayCountfraction
         , margin
         , observedRate
         , notionalAmount
         , paymentDate
         , forecastRateIndex
         , discountingType
         , discountRate
         , fraDiscounting
         )
 {
 }
Ejemplo n.º 2
0
        public static FloatingRateDefinition CreateFloatingRateDefinition(FloatingRate floatingRate,
                                                                          DayCountFraction dayCountFraction,
                                                                          CalculationPeriod calculationPeriod,
                                                                          IRateCurve forecastCurve)
        {
            //throw new NotImplementedException();
            // assign floating rate def with adjusted fixing date
            //
            var floatingRateDefinition = new FloatingRateDefinition {
                spread = 0.000m, spreadSpecified = true
            };
            // Spread = 0.0
            //
            var rateObservation = new RateObservation();

            floatingRateDefinition.rateObservation = new[] { rateObservation };
            rateObservation.forecastRate           = GetForecastRate(calculationPeriod, forecastCurve, dayCountFraction);
            rateObservation.forecastRateSpecified  = true;
            Decimal finalRate = rateObservation.forecastRate;

            // If spread specified - add it to final rate.
            //
            if (floatingRateDefinition.spreadSpecified)
            {
                finalRate += floatingRateDefinition.spread;
            }
            floatingRateDefinition.calculatedRate          = finalRate;
            floatingRateDefinition.calculatedRateSpecified = true;
            return(floatingRateDefinition);
        }
 /// <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;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableCapFloorCoupon"/> class.
 /// </summary>
 /// <param name="cashlFowId">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="margin">The margin.</param>
 /// <param name="observedRate">The observed Rate. If this is not null, then it is used.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="adjustedFixingDate">The adjusted fixing date.</param>
 /// <param name="dayCountFraction">Type of day Count fraction.</param>
 /// <param name="paymentDate">The payment date.</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 cashlFowId
     , bool buyerIsBase
     , decimal?capStrike
     , decimal?floorStrike
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , DateTime adjustedFixingDate
     , DayCountFraction dayCountFraction
     , Decimal margin
     , Decimal?observedRate
     , Money notionalAmount
     , DateTime paymentDate
     , ForecastRateIndex forecastRateIndex
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting
     , IBusinessCalendar fixingCalendar
     , IBusinessCalendar paymentCalendar)
     : base(
         cashlFowId
         , buyerIsBase
         , accrualStartDate
         , accrualEndDate
         , adjustedFixingDate
         , dayCountFraction
         , 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";
     }
 }
 /// <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);
 }
        public static DayCountFraction ToDayCountFraction(DayCountFractionEnum dayCountFractionEnum)
        {
            string dayCountFractionString = DayCountFractionScheme.GetEnumString(dayCountFractionEnum);
            var    result = new DayCountFraction {
                Value = dayCountFractionString
            };

            return(result);
        }
Ejemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="cache">The cache.</param>
 /// <param name="baseParty">THe base party is either Party1 or Party2</param>
 /// <param name="depositFpML">THe FpML representation of the deposit correctly built.</param>
 public TermDepositPricer(ILogger logger, ICoreCache cache, TermDeposit depositFpML, string baseParty)
 {
     Multiplier        = 1.0m;
     OrderedPartyNames = new List <string>();
     FixedRate         = depositFpML.fixedRate;
     EffectiveDate     = depositFpML.startDate;
     TerminationDate   = depositFpML.maturityDate;
     DayCountFraction  = new DayCountFraction {
         Value = depositFpML.dayCountFraction.Value
     };
     BasePartyPayingFixed = !IsBasePartyLender(baseParty, depositFpML);
     if (BasePartyPayingFixed)//From the viewpoint of the counterparty!
     {
         BaseParty    = depositFpML.receiverPartyReference.href;
         CounterParty = depositFpML.payerPartyReference.href;
     }
     else
     {
         BaseParty    = depositFpML.payerPartyReference.href;
         CounterParty = depositFpML.receiverPartyReference.href;
     }
     PaymentDate      = TerminationDate;
     RiskMaturityDate = TerminationDate;
     Principal        = MoneyHelper.GetMoney(depositFpML.principal);
     Payments         = new List <PriceablePayment>();
     if (depositFpML.payment != null && depositFpML.payment.Length == 3)
     {
         //Modify to be principal and interest.
         //A principal payment ->priceable payment
         //An interest payment -> priceable fixed coupon
         var initialDate  = AdjustableOrAdjustedDateHelper.Create(null, EffectiveDate, null);
         var maturityDate = AdjustableOrAdjustedDateHelper.Create(null, PaymentDate, null);
         depositFpML.payment[0].paymentDate = initialDate;
         depositFpML.payment[1].paymentDate = maturityDate;
         depositFpML.payment[2].paymentDate = maturityDate;//Remove this and replace with depositFpML.interest
         Payments.AddRange(PriceableInstrumentsFactory.CreatePriceablePayments(BaseParty, depositFpML.payment, null));
         AddCashFlow(depositFpML, BasePartyPayingFixed);
     }
     else//This will change the input FpML as well!
     {
         var initial = PaymentHelper.Create(depositFpML.payerPartyReference.href, depositFpML.receiverPartyReference.href, Principal.currency.Value, Principal.amount, EffectiveDate);
         Payments.Add(PriceableInstrumentsFactory.CreatePriceablePayment(BaseParty, initial, null));
         var final = PaymentHelper.Create(depositFpML.receiverPartyReference.href, depositFpML.payerPartyReference.href, depositFpML.principal.currency.Value, Principal.amount, TerminationDate);
         Payments.Add(PriceableInstrumentsFactory.CreatePriceablePayment(BaseParty, final, null));
         //Payments.Add(PaymentHelper.Create("interest payment");
         AddCashFlow(depositFpML, !BasePartyPayingFixed);
     }
     //Set the product type.
     ProductType       = ProductTypeSimpleEnum.TermDeposit;
     Currency          = depositFpML.principal.currency;
     PaymentCurrencies = new List <string> {
         Currency.Value
     };
     //Set the default discount curve name.
     DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true);
 }
Ejemplo n.º 8
0
        public static Discounting Create(decimal discountingRate, DayCountFraction dayCountFraction, DiscountingTypeEnum discountingTypeEnum)
        {
            var discounting = new Discounting
            {
                discountingType = discountingTypeEnum,
                discountRate    = discountingRate,
                discountRateDayCountFraction = dayCountFraction
                                               //discountRateSpecified = true
            };

            return(discounting);
        }
Ejemplo n.º 9
0
        public static Discounting Create(decimal?discountingRate, DayCountFraction dayCountFraction, DiscountingTypeEnum discountingTypeEnum)
        {
            var discounting = new Discounting
            {
                discountingType = discountingTypeEnum,
                discountRateDayCountFraction = dayCountFraction
                                               //discountRateSpecified = true
            };

            if (discountingRate != null)
            {
                discounting.discountRate = (decimal)discountingRate;
            }
            return(discounting);
        }
Ejemplo n.º 10
0
        public static Calculation CreateFloating(decimal fixedRate, Money notional, FloatingRateIndex floatingRateIndex, Period tenor,
                                                 DayCountFraction dayCountFraction, DiscountingTypeEnum discountingType)
        {
            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notional),
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting =
                    DiscountingHelper.Create(fixedRate, dayCountFraction, discountingType),
                Items = new object[] { FloatingRateCalculationHelper.CreateFloating(floatingRateIndex, tenor) }
            };

            return(calculation);
        }
 /// <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)
 {
 }
Ejemplo n.º 12
0
 /// <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();
 }
 /// <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="margin">The margin.</param>
 /// <param name="baseRate">The base rate for a nettable fixed/floating cash flow. </param>
 /// <param name="observedRate">The observed Rate. If this is not null, then it is used.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="adjustedFixingDate">The adjusted fixing date.</param>
 /// <param name="dayCountfraction">Type of day Countfraction.</param>
 /// <param name="paymentDate">The payment date.</param>
 /// <param name="forecastRateIndex">The forecastrate 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 fradiscounting</param>
 /// <param name="fixingCalendar">The fixingCalendar.</param>
 /// <param name="paymentCalendar">The paymentCalendar.</param>
 public PriceableFloatingRateCoupon
 (
     string cashlfowId
     , bool payerIsBase
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , DateTime adjustedFixingDate
     , DayCountFraction dayCountfraction
     , Decimal margin
     , Decimal baseRate
     , Decimal?observedRate
     , Money notionalAmount
     , DateTime paymentDate
     , ForecastRateIndex forecastRateIndex
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting
     , IBusinessCalendar fixingCalendar
     , IBusinessCalendar paymentCalendar)
     : base(
         cashlfowId
         , CouponType.FloatingRate
         , payerIsBase
         , accrualStartDate
         , accrualEndDate
         , notionalAmount
         , dayCountfraction
         , observedRate
         , paymentDate
         , discountingType
         , discountRate
         , fraDiscounting
         , paymentCalendar)
 {
     BaseRate        = baseRate;
     FixingCalendar  = fixingCalendar;
     ModelIdentifier = "DualCurveCouponModel";
     Id = cashlfowId;
     ForecastRateIndex  = forecastRateIndex;
     Margin             = margin;
     AdjustedFixingDate = adjustedFixingDate;
     RateObservation    = RateObservationHelper.Parse(AdjustedFixingDate, observedRate, "1");
     SetRateObservation(RateObservation, ResetDate);
     ForecastCurveName = CurveNameHelpers.GetForecastCurveName(forecastRateIndex);
 }
Ejemplo n.º 14
0
        public static Calculation CreateFixed(decimal fixedRate, NonNegativeAmountSchedule notionalSchedule,
                                              DayCountFraction dayCountFraction, DiscountingTypeEnum?discountingType)
        {
            var discounting = discountingType != null
                                  ? DiscountingHelper.Create(fixedRate, dayCountFraction, (DiscountingTypeEnum)discountingType)
                                  : null;

            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notionalSchedule),
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting = discounting,
                Items       = new object[] { FixedRateScheduleHelper.Create(fixedRate) }
            };

            return(calculation);
        }
Ejemplo n.º 15
0
        public static void UpdateFloatingRateDefinition(FloatingRateDefinition floatingRateDefinition,
                                                        FloatingRateCalculation floatingRateCalculation,
                                                        DayCountFraction dayCountFraction,
                                                        CalculationPeriod calculationPeriod,
                                                        IRateCurve forecastCurve)
        {
            var rateObservation = new RateObservation();

            if (floatingRateDefinition.rateObservation != null)
            {
                if (floatingRateDefinition.rateObservation[0].adjustedFixingDateSpecified)
                {
                    rateObservation.adjustedFixingDate          = floatingRateDefinition.rateObservation[0].adjustedFixingDate;
                    rateObservation.adjustedFixingDateSpecified = true;
                }
            }
            floatingRateDefinition.rateObservation = new[] { rateObservation };
            rateObservation.forecastRate           = GetForecastRate(calculationPeriod, forecastCurve, dayCountFraction);
            rateObservation.forecastRateSpecified  = true;
            Decimal finalRate = rateObservation.forecastRate;

            // If spread specified - add it to the final rate.
            //
            if (floatingRateDefinition.spreadSpecified)
            {
                finalRate += floatingRateDefinition.spread;
            }
            // Apply rounding (if it's been specified)
            //
            if (null != floatingRateCalculation.finalRateRounding)
            {
                Rounding finalRateRounding = floatingRateCalculation.finalRateRounding;
                floatingRateDefinition.calculatedRate = RoundingHelper.Round(finalRate, finalRateRounding);
            }
            else
            {
                floatingRateDefinition.calculatedRate = finalRate;
            }
            floatingRateDefinition.calculatedRateSpecified = true;
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableRateCoupon"/> class.
 /// This is only used for Xibor type structured coupons with convexity adjustments and only
 /// in the same currency i.e. there is no quanto effects.
 /// </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="calculationDayCountFraction">The daycountfraction used for the calculation period i.e. the index calculation.</param>
 /// <param name="margin">The margin.</param>
 /// <param name="observedRate">The observed Rate. If this is not null, then it is used.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="adjustedFixingDate">The adjusted fixing date.</param>
 /// <param name="calculationStartDate">The calculation start date.</param>
 /// <param name="calculationEndDate">The calculation end date.</param>
 /// <param name="accrualDayCountfraction">Type of dayCountfraction use for the the accrual period.</param>
 /// <param name="paymentDate">The payment date.</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="calculationStartDate"></param>
 /// then it is assumed that there is no fradiscounting</param>
 public PriceableStructuredRateCoupon
 (
     string cashlfowId
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , DateTime adjustedFixingDate
     , DateTime calculationStartDate
     , DateTime calculationEndDate
     , DayCountFraction accrualDayCountfraction
     , DayCountFraction calculationDayCountFraction
     , Decimal margin
     , Decimal?observedRate
     , Money notionalAmount
     , DateTime paymentDate
     , ForecastRateIndex forecastRateIndex
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting)
     : base(
         cashlfowId
         , accrualStartDate
         , accrualEndDate
         , adjustedFixingDate
         , accrualDayCountfraction
         , margin
         , observedRate
         , notionalAmount
         , paymentDate
         , forecastRateIndex
         , discountingType
         , discountRate
         , fraDiscounting
         )
 {
     CalculationStartDate        = calculationStartDate;
     CalculationEndDate          = calculationEndDate;
     CalculationDayCountFraction = calculationDayCountFraction;
     PriceableCouponType         = CouponType.StructuredRate;
     AnalyticsModel = new StructuredRateCouponAnalytic();
 }
Ejemplo n.º 17
0
        public static RateIndex Create(string instrumentId,
                                       FloatingRateIndex floatingRateIndex,
                                       Currency currency,
                                       DayCountFraction dayCountFraction,
                                       Period paymentFrequency,
                                       Period term)
        {
            var rateIndex = new RateIndex
            {
                currency = new IdentifiedCurrency {
                    Value = currency.Value
                },
                dayCountFraction  = dayCountFraction,
                floatingRateIndex = floatingRateIndex,
                id               = instrumentId,
                instrumentId     = InstrumentIdArrayHelper.Parse(instrumentId),
                paymentFrequency = paymentFrequency,
                term             = term
            };

            return(rateIndex);
        }
 /// <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="margin">The margin.</param>
 /// <param name="observedRate">The observed Rate. If this is not null, then it is used.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="adjustedFixingDate">The adjusted fixing date.</param>
 /// <param name="dayCountfraction">Type of day Countfraction.</param>
 /// <param name="paymentDate">The payment date.</param>
 /// <param name="forecastRateIndex">The forecastrate 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 fradiscounting</param>
 /// <param name="fixingCalendar">The fixingCalendar.</param>
 /// <param name="paymentCalendar">The paymentCalendar.</param>
 public PriceableFloatingRateCoupon
 (
     string cashlfowId
     , bool payerIsBase
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , DateTime adjustedFixingDate
     , DayCountFraction dayCountfraction
     , Decimal margin
     , Decimal?observedRate
     , Money notionalAmount
     , DateTime paymentDate
     , ForecastRateIndex forecastRateIndex
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting
     , IBusinessCalendar fixingCalendar
     , IBusinessCalendar paymentCalendar)
     : this(
         cashlfowId
         , payerIsBase
         , accrualStartDate
         , accrualEndDate
         , adjustedFixingDate
         , dayCountfraction
         , margin
         , 0.0m
         , observedRate
         , notionalAmount
         , paymentDate
         , forecastRateIndex
         , discountingType
         , discountRate
         , fraDiscounting
         , fixingCalendar
         , paymentCalendar)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 /// PriceableBond
 /// </summary>
 /// <param name="name"></param>
 /// <param name="instrumentid"></param>
 /// <param name="bondType"></param>
 /// <param name="dealDate"></param>
 /// <param name="valueDate"></param>
 /// <param name="ccy"></param>
 /// <param name="calendar"></param>
 /// <param name="coupFreq"></param>
 /// <param name="accrualDC"></param>
 /// <param name="yieldDC"></param>
 /// <param name="repoDC"></param>
 /// <param name="xdt"></param>
 /// <param name="couponType"></param>
 /// <param name="couponRate"></param>
 /// <param name="settC"></param>
 /// <param name="maturity"></param>
 /// <param name="valueC"></param>
 /// <param name="tickSize"></param>
 /// <param name="issuerName"></param>
 /// <param name="ycm"></param>
 /// <param name="yieldCompFreq"></param>
 /// <param name="accIntRounding"></param>
 public PriceableBond(string name, string instrumentid, string bondType,
                      DateTime dealDate, DateTime valueDate, Currency ccy, IBusinessCalendar calendar,
                      Period coupFreq, DayCountFraction accrualDC, DayCountFraction yieldDC, DayCountFraction repoDC,
                      ExDividendEnum xdt, CouponTypeEnum couponType, decimal couponRate, string settC, DateTime maturity,
                      BondSettlementEnum valueC, short tickSize, string issuerName, BondAnalytics.YieldCalcMethod ycm,
                      short yieldCompFreq, short accIntRounding)
     : base(dealDate, 100.0m, ccy, null, null, null, null)
 {
     Currency            = ccy;
     ValueDate           = valueDate;
     DealDate            = dealDate;
     Frequency           = int.Parse(coupFreq.periodMultiplier); //convert to using the bond fpml paymentfrequency field.
     AccIntRounding      = accIntRounding;
     CouponType          = couponType;
     CouponRate          = couponRate;
     CouponDayCount      = accrualDC;
     BondType            = EnumHelper.Parse <BondTypesEnum>(bondType);
     PaymentDateCalendar = calendar;
     RepoDC          = repoDC;
     SettC           = settC;
     TickSize        = tickSize;
     ValueC          = valueC;
     Xdt             = xdt;
     Ycm             = ycm;
     YieldCompFreq   = yieldCompFreq;
     YieldDC         = yieldDC;
     RollDay         = maturity.Day;   //provide an input for this.
     ValueDate       = SettlementDate; //default condition if not specified.
     Id              = name;
     Issuer          = issuerName;     //Does not handle PartyReference type -> only string!
     MaturityDate    = maturity;
     CouponFrequency = coupFreq;
     CouponType      = CouponTypeEnum.Fixed;
     InstrumentIds   = new List <InstrumentId> {
         InstrumentIdHelper.Parse(instrumentid)
     };
     Build();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableRateCoupon"/> class.
 /// </summary>
 /// <param name="cashflowId">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="fixedRate">The fixed rate.</param>
 /// <param name="payerIsBase">The payer is base flag.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="dayCountFraction">Type of day Count fraction.</param>
 /// <param name="expectedAmount">The expected amount. This is normally null, unless a calculated amount is overwritten.</param>
 /// <param name="paymentDate">The payment date.</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
     , DayCountFraction dayCountFraction
     , Decimal fixedRate
     , Money notionalAmount
     , Money expectedAmount
     , DateTime paymentDate
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting
     , IBusinessCalendar paymentCalendar)
     : base(cashflowId, CouponType.FixedRate, payerIsBase, accrualStartDate, accrualEndDate,
            notionalAmount, dayCountFraction, fixedRate, paymentDate, discountingType, discountRate,
            fraDiscounting, paymentCalendar)
 {
     ForecastAmount = expectedAmount;
     Id             = cashflowId;
     CalculatePaymentAmount(0);
     ForecastAmount = PaymentAmount;
 }
Ejemplo n.º 21
0
        ///<summary>
        ///</summary>
        ///<param name="baseDate"></param>
        ///<param name="frequency"></param>
        ///<param name="dayCountFraction"></param>
        ///<returns></returns>
        ///<exception cref="NotImplementedException"></exception>
        public static decimal PeriodFractionFromCompoundingFrequency(DateTime baseDate, CompoundingFrequencyEnum frequency, DayCountFraction dayCountFraction)
        {
            switch (frequency)
            {
            case CompoundingFrequencyEnum.Continuous:
                return(0.0m);

            case CompoundingFrequencyEnum.Daily:
                IDayCounter dc = DayCounterHelper.Parse(dayCountFraction.Value);
                return((decimal)dc.YearFraction(baseDate, baseDate.AddDays(1.0d)));

            case CompoundingFrequencyEnum.Weekly:
                return((decimal)1 / 52);

            case CompoundingFrequencyEnum.Monthly:
                return((decimal)1 / 12);

            case CompoundingFrequencyEnum.Quarterly:
                return((decimal)1 / 4);

            case CompoundingFrequencyEnum.SemiAnnual:
                return((decimal)1 / 2);

            case CompoundingFrequencyEnum.Annual:
                return(1.0m);

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 22
0
 ///<summary>
 ///</summary>
 ///<param name="baseDate"></param>
 ///<param name="frequency"></param>
 ///<param name="dayCountFraction"></param>
 ///<returns></returns>
 ///<exception cref="NotImplementedException"></exception>
 public static decimal PeriodFractionFromCompoundingFrequency(DateTime baseDate, CompoundingFrequency frequency, DayCountFraction dayCountFraction)
 {
     return(PeriodFractionFromCompoundingFrequency(baseDate, frequency.ToEnum(), dayCountFraction));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets the year fractions for dates.
        /// </summary>
        /// <param name="periodDates">The period dates.</param>
        /// <param name="dayCountFraction">The day count fraction.</param>
        /// <returns></returns>
        public static decimal[] GetYearFractionsForDates(IList <DateTime> periodDates, DayCountFraction dayCountFraction)
        {
            var yearFractions        = new List <decimal>();
            var index                = 0;
            var periodDatesLastIndex = periodDates.Count - 1;

            foreach (var periodDate in periodDates)
            {
                if (index == periodDatesLastIndex)
                {
                    break;
                }
                var yearFraction =
                    (decimal)
                    DayCounterHelper.Parse(dayCountFraction.Value).YearFraction(periodDate,
                                                                                periodDates[index + 1]);
                yearFractions.Add(yearFraction);
                index++;
            }
            return(yearFractions.ToArray());
        }
Ejemplo n.º 24
0
        private static decimal GetForecastRate(CalculationPeriod calculationPeriod, IRateCurve forecastCurve, DayCountFraction dayCountFraction)
        {
            double      startOfPeriodDiscount = forecastCurve.GetDiscountFactor(calculationPeriod.adjustedStartDate);
            double      endOfPeriodDiscount   = forecastCurve.GetDiscountFactor(calculationPeriod.adjustedEndDate);
            IDayCounter dayCounter            = DayCounterHelper.Parse(dayCountFraction.Value);
            double      accrualPeriod         = dayCounter.YearFraction(calculationPeriod.adjustedStartDate, calculationPeriod.adjustedEndDate);

            if (0 == accrualPeriod)
            {
                string message =
                    $"Accrual period is 0 days. calculationPeriod.adjustedStartDate = '{calculationPeriod.adjustedStartDate}', calculationPeriod.adjustedEndDate = '{calculationPeriod.adjustedEndDate}'";
                throw new System.Exception(message);
            }
            double forecastContinuouslyCompoundingRate = (startOfPeriodDiscount / endOfPeriodDiscount - 1.0) / accrualPeriod;

            return((decimal)forecastContinuouslyCompoundingRate);
        }
Ejemplo n.º 25
0
        public static Calculation CreateFixed(decimal fixedRate, decimal discountRate, Money notional,
                                              CompoundingMethodEnum compoundingMethod, DayCountFraction dayCountFraction, DiscountingTypeEnum discountingType)
        {
            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notional),
                compoundingMethod          = compoundingMethod,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting =
                    DiscountingHelper.Create(discountRate, dayCountFraction,
                                             discountingType),
                Items = new object[] { FixedRateScheduleHelper.Create(fixedRate) }
            };

            return(calculation);
        }
Ejemplo n.º 26
0
        public static Calculation CreateFloating(Money notional, FloatingRateIndex floatingRateIndex, Period tenor, DayCountFraction dayCountFraction, DiscountingTypeEnum discountingType)
        {
            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notional),
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction
            };

            var discounting = new Discounting
            {
                discountingType = discountingType,
                discountRateDayCountFraction = dayCountFraction
            };

            calculation.discounting = discounting;
            calculation.Items       = new object[] { FloatingRateCalculationHelper.CreateFloating(floatingRateIndex, tenor) };

            return(calculation);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableXibor"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="amount">The amount.</param>
 /// <param name="effectiveDate">The effective date.</param>
 /// <param name="riskMaturityDate">The risk maturity date.</param>
 /// <param name="dayCountFraction">The day count fraction.</param>
 public PriceableXibor(string id, Decimal amount, DateTime effectiveDate, DateTime riskMaturityDate, DayCountFraction dayCountFraction)
     : base(id, amount, effectiveDate, riskMaturityDate)
 {
     YearFraction = GetYearFraction(dayCountFraction.Value, effectiveDate, riskMaturityDate);
 }
Ejemplo n.º 28
0
 /// <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";
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Gets the year fractions for dates.
        /// </summary>
        /// <param name="periodDates">The period dates.</param>
        /// <param name="dayCountFraction">The day count fraction.</param>
        /// <returns></returns>
        protected static List <double> GetYearFractionsForDates(IList <DateTime> periodDates, DayCountFraction dayCountFraction)
        {
            var yearFractions        = new List <double>();
            var index                = 0;
            var periodDatesLastIndex = periodDates.Count - 1;

            foreach (var periodDate in periodDates)
            {
                if (index == periodDatesLastIndex)
                {
                    break;
                }
                var yearFraction =
                    DayCounterHelper.Parse(dayCountFraction.Value).YearFraction(periodDate,
                                                                                periodDates[index + 1]);
                yearFractions.Add(yearFraction);
                index++;
            }
            return(yearFractions);
        }
Ejemplo n.º 30
0
        public static Trade CreateFraTrade(string tradeId, RequiredIdentifierDate adjustedEffectiveDate, DateTime adjustedTerminationDate,
                                           AdjustableDate paymentDate, RelativeDateOffset fixingDayOffset, DayCountFraction dayCountFraction, decimal notionalAmount,
                                           string notionalCurrency, decimal fixedRate, string floatingRateIndex, string indexTenor, FraDiscountingEnum fraDiscounting)
        {
            var trade = new Trade();
            var fra   = new Fra
            {
                adjustedEffectiveDate            = adjustedEffectiveDate,
                adjustedTerminationDate          = adjustedTerminationDate,
                adjustedTerminationDateSpecified = true,
                paymentDate = paymentDate,
                Items       = new object[] { new ProductType {
                                                 Value = ProductTypeSimpleEnum.FRA.ToString()
                                             } },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };

            if ("resetDate" != fixingDayOffset.dateRelativeTo.href)
            {
                throw new ArgumentException("The fixing date must be specified as 'resetDate'-relative!", nameof(fixingDayOffset));
            }
            fra.fixingDateOffset = fixingDayOffset;
            fra.dayCountFraction = dayCountFraction;
            IDayCounter dayCounter = DayCounterHelper.Parse(fra.dayCountFraction.Value);

            fra.calculationPeriodNumberOfDays = dayCounter.DayCount(fra.adjustedEffectiveDate.Value, fra.adjustedTerminationDate).ToString(CultureInfo.InvariantCulture);
            fra.notional                = MoneyHelper.GetAmount(notionalAmount, notionalCurrency);
            fra.fixedRate               = fixedRate;
            fra.fixedRateSpecified      = true;
            fra.floatingRateIndex       = FloatingRateIndexHelper.Parse(floatingRateIndex);
            fra.indexTenor              = new[] { PeriodHelper.Parse(indexTenor) };
            fra.fraDiscounting          = fraDiscounting;
            fra.fraDiscountingSpecified = true;
            PartyReference party1 = PartyReferenceFactory.Create("party1");
            PartyReference party2 = PartyReferenceFactory.Create("party2");

            fra.sellerPartyReference = party2;
            fra.buyerPartyReference  = party1;
            XsdClassesFieldResolver.TradeSetFra(trade, fra);
            trade.id = tradeId;
            return(trade);
        }