public static void SetNotionalAmount(PaymentCalculationPeriod paymentCalculationPeriod, decimal notionalAmount) { foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { XsdClassesFieldResolver.CalculationPeriodSetNotionalAmount(calculationPeriod, notionalAmount); } }
public static TermPoint Create(decimal mid, DateTime term) { var termPoint = new TermPoint { mid = mid, midSpecified = true }; var timeDimension = new TimeDimension(); XsdClassesFieldResolver.TimeDimensionSetDate(timeDimension, term); termPoint.term = timeDimension; return(termPoint); }
public static decimal GetNotionalAmount(PaymentCalculationPeriod paymentCalculationPeriod) { decimal result = 0.0m; decimal numberOfPeriods = 0.0m; foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { result += XsdClassesFieldResolver.CalculationPeriodGetNotionalAmount(calculationPeriod); numberOfPeriods += 1; } return(result / numberOfPeriods); }
public static void SetSpread(PaymentCalculationPeriod paymentCalculationPeriod, decimal value) { foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { if (XsdClassesFieldResolver.CalculationPeriodHasFloatingRateDefinition(calculationPeriod)) { FloatingRateDefinition floatingRateDefinition = XsdClassesFieldResolver.CalculationPeriodGetFloatingRateDefinition(calculationPeriod); floatingRateDefinition.spread = value; floatingRateDefinition.spreadSpecified = true; } else { throw new NotImplementedException("PaymentCalculationPeriodHelper.SetSpread cannot be called on a fixed rate cashflow."); } } }
public static void SetRate(PaymentCalculationPeriod paymentCalculationPeriod, decimal rate) { foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { if (XsdClassesFieldResolver.CalculationPeriodHasFixedRate(calculationPeriod)) { XsdClassesFieldResolver.SetCalculationPeriodFixedRate(calculationPeriod, rate); } else if (XsdClassesFieldResolver.CalculationPeriodHasFloatingRateDefinition(calculationPeriod)) { throw new NotImplementedException("Cannot modify floating rate, PaymentCalculationPeriodHelper.SetRate"); //XsdClassesFieldResolver.CalculationPeriod_GetFloatingRateDefinition(calculationPeriod).calculatedRate; } else { throw new NotImplementedException("PaymentCalculationPeriodHelper.SetRate"); } } }
public static Swaption Create(Swap swap, Payment[] premium, EuropeanExercise exercise, bool automaticExercise) { var swaption = new Swaption { swap = swap, premium = premium }; var europeanExercise = exercise; swaption.exerciseProcedure = new ExerciseProcedure(); if (automaticExercise) { XsdClassesFieldResolver.ExerciseProcedureSetAutomaticExercise(swaption.exerciseProcedure, new AutomaticExercise()); } else//manual exercise { XsdClassesFieldResolver.ExerciseProcedureSetManualExercise(swaption.exerciseProcedure, new ManualExercise()); } XsdClassesFieldResolver.SwaptionSetEuropeanExercise(swaption, europeanExercise); return(swaption); }
public static decimal GetSpread(PaymentCalculationPeriod paymentCalculationPeriod) { decimal result = 0.0m; decimal numberOfPeriods = 0.0m; foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { if (XsdClassesFieldResolver.CalculationPeriodHasFloatingRateDefinition(calculationPeriod)) { FloatingRateDefinition floatingRateDefinition = XsdClassesFieldResolver.CalculationPeriodGetFloatingRateDefinition(calculationPeriod); result += floatingRateDefinition.spread; } else { throw new NotImplementedException("PaymentCalculationPeriodHelper.GetSpread cannot be called on fixed rate cashflow."); } numberOfPeriods += 1; } return(result / numberOfPeriods); }
public static void ReplaceFloatingRateWithFixedRate(PaymentCalculationPeriod paymentCalculationPeriod, decimal fixedRate) { foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { if (XsdClassesFieldResolver.CalculationPeriodHasFixedRate(calculationPeriod)) { throw new System.Exception("calculation period already uses a fixed rate."); } if (XsdClassesFieldResolver.CalculationPeriodHasFloatingRateDefinition(calculationPeriod)) { // Replace FloatingRateDefinition with decimal (fixed rate) // XsdClassesFieldResolver.SetCalculationPeriodFixedRate(calculationPeriod, fixedRate); } else { throw new NotSupportedException("PaymentCalculationPeriodHelper.ReplaceFloatingRateWithFixedRate"); } } }
public static Swaption Create(Swap swap, decimal premiumAmount, DateTime expirationDate) { var swaption = new Swaption { swap = swap, premium = new[] { new Payment() } }; swaption.premium[0].paymentAmount = MoneyHelper.GetNonNegativeAmount(premiumAmount); var europeanExercise = new EuropeanExercise { expirationDate = new AdjustableOrRelativeDate() }; var adjustableDate = new AdjustableDate { unadjustedDate = new IdentifiedDate { Value = expirationDate } }; europeanExercise.expirationDate.Item = adjustableDate; XsdClassesFieldResolver.SwaptionSetEuropeanExercise(swaption, europeanExercise); return(swaption); }
public static decimal GetRate(PaymentCalculationPeriod paymentCalculationPeriod) { decimal result = 0.0m; decimal numberOfPeriods = 0.0m; foreach (CalculationPeriod calculationPeriod in XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)) { if (XsdClassesFieldResolver.CalculationPeriodHasFixedRate(calculationPeriod)) { result += XsdClassesFieldResolver.CalculationPeriodGetFixedRate(calculationPeriod); } else if (XsdClassesFieldResolver.CalculationPeriodHasFloatingRateDefinition(calculationPeriod)) { result += XsdClassesFieldResolver.CalculationPeriodGetFloatingRateDefinition(calculationPeriod).calculatedRate; } else { throw new NotImplementedException("PaymentCalculationPeriodHelper.GetRate"); } numberOfPeriods += 1; } return(result / numberOfPeriods); }
public static Swaption Create(Swap swap, NonNegativeMoney premium, string premiumPayer, string premiumReceiver, AdjustableOrAdjustedDate paymentDate, AdjustableDate expirationDate, DateTime earliestExerciseTime, DateTime expirationTime, bool automaticExercise) { var swaption = new Swaption { swap = swap, premium = new[] { new Payment() }, buyerPartyReference = PartyReferenceHelper.Parse(premiumPayer), sellerPartyReference = PartyReferenceHelper.Parse(premiumReceiver) }; swaption.premium[0].paymentAmount = premium; swaption.premium[0].paymentDate = paymentDate; swaption.premium[0].payerPartyReference = PartyReferenceHelper.Parse(premiumPayer); swaption.premium[0].receiverPartyReference = PartyReferenceHelper.Parse(premiumReceiver); var europeanExercise = new EuropeanExercise { expirationDate = new AdjustableOrRelativeDate(), earliestExerciseTime = BusinessCenterTimeHelper.Create(earliestExerciseTime), expirationTime = BusinessCenterTimeHelper.Create(expirationTime) }; europeanExercise.expirationDate.Item = expirationDate; swaption.exerciseProcedure = new ExerciseProcedure(); if (automaticExercise) { XsdClassesFieldResolver.ExerciseProcedureSetAutomaticExercise(swaption.exerciseProcedure, new AutomaticExercise()); } else//manual exercise { XsdClassesFieldResolver.ExerciseProcedureSetManualExercise(swaption.exerciseProcedure, new ManualExercise()); } XsdClassesFieldResolver.SwaptionSetEuropeanExercise(swaption, europeanExercise); return(swaption); }
public static CalculationPeriod GetFirstCalculationPeriod(PaymentCalculationPeriod paymentCalculationPeriod) { return(XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)[0]); }
public static CalculationPeriod[] GetCalculationPeriods(PaymentCalculationPeriod paymentCalculationPeriod) { return(XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod)); }
public static void SetCalculationPeriodEndDate(PaymentCalculationPeriod paymentCalculationPeriod, DateTime endDate) { CalculationPeriod[] calculationPeriodArray = XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod); calculationPeriodArray[calculationPeriodArray.Length - 1].adjustedEndDate = endDate; calculationPeriodArray[calculationPeriodArray.Length - 1].adjustedEndDateSpecified = true; }
public static DateTime GetCalculationPeriodEndDate(PaymentCalculationPeriod paymentCalculationPeriod) { CalculationPeriod[] calculationPeriodArray = XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod); return(calculationPeriodArray[calculationPeriodArray.Length - 1].adjustedEndDate); }
public static void SetCalculationPeriodStartDate(PaymentCalculationPeriod paymentCalculationPeriod, DateTime startDate) { CalculationPeriod[] calculationPeriodArray = XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod); calculationPeriodArray[0].adjustedStartDate = startDate; calculationPeriodArray[0].adjustedStartDateSpecified = true; }
public static DateTime GetCalculationPeriodStartDate(PaymentCalculationPeriod paymentCalculationPeriod) { CalculationPeriod[] calculationPeriodArray = XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod); return(calculationPeriodArray[0].adjustedStartDate); }
public static int GetNumberOfDays(PaymentCalculationPeriod paymentCalculationPeriod) { return(XsdClassesFieldResolver.GetPaymentCalculationPeriodCalculationPeriodArray(paymentCalculationPeriod).Sum(calculationPeriod => int.Parse(calculationPeriod.calculationPeriodNumberOfDays))); }
public static DateTime GetDate(TermPoint termPoint) { DateTime date = XsdClassesFieldResolver.TimeDimensionGetDate(termPoint.term); return(date); }