public static AdjustableOrAdjustedDate CreateUnadjustedDate(DateTime unadjustedDate, BusinessDayAdjustments businessDayAdjustments) { var date = new AdjustableOrAdjustedDate(); var identifiedDate = IdentifiedDateHelper.Create(ItemsChoiceType.unadjustedDate.ToString(), unadjustedDate); object[] items; ItemsChoiceType[] itemsElementName; if (businessDayAdjustments != null) { items = new object[2]; items[0] = identifiedDate; items[1] = businessDayAdjustments; itemsElementName = new ItemsChoiceType[2]; itemsElementName[0] = ItemsChoiceType.unadjustedDate; itemsElementName[1] = ItemsChoiceType.dateAdjustments; } else { items = new object[1]; items[0] = identifiedDate; itemsElementName = new ItemsChoiceType[1]; itemsElementName[0] = ItemsChoiceType.unadjustedDate; } date.Items = items; date.ItemsElementName = itemsElementName; return(date); }
public static AdjustableOrAdjustedDate Create(DateTime?unadjustedDate, DateTime?adjustedDate, BusinessDayAdjustments businessDayAdjustments) { var date = new AdjustableOrAdjustedDate(); var items = new List <object>(); var itemsElementName = new List <ItemsChoiceType>(); if (unadjustedDate == null && adjustedDate == null) { return(date); } if (unadjustedDate != null) { items.Add(IdentifiedDateHelper.Create(ItemsChoiceType.unadjustedDate.ToString(), (DateTime)unadjustedDate)); itemsElementName.Add(ItemsChoiceType.unadjustedDate); } if (adjustedDate != null) { items.Add(IdentifiedDateHelper.Create(ItemsChoiceType.adjustedDate.ToString(), (DateTime)adjustedDate)); itemsElementName.Add(ItemsChoiceType.adjustedDate); } if (businessDayAdjustments != null) { items.Add(businessDayAdjustments); itemsElementName.Add(ItemsChoiceType.dateAdjustments); } date.Items = items.ToArray(); date.ItemsElementName = itemsElementName.ToArray(); return(date); }
/// <summary> /// Gets the yield curve valuation. /// </summary> /// <returns></returns> public YieldCurveValuation GetYieldCurveValuation() { var yieldCurveValuation = new YieldCurveValuation { baseDate = IdentifiedDateHelper.Create(DateTime.MinValue) }; return(yieldCurveValuation); }
/// <summary> /// GetYieldCurveValuation /// </summary> /// <returns></returns> public YieldCurveValuation GetYieldCurveValuation() { var yieldCurveValuation = new YieldCurveValuation { baseDate = IdentifiedDateHelper.Create(BaseDate), discountFactorCurve = null }; return(yieldCurveValuation); }
/// <summary> /// GetYieldCurveValuation /// </summary> /// <returns></returns> public VolatilityMatrix GetVolatilityMatrix() { var volatilityMatrix = new VolatilityMatrix { baseDate = IdentifiedDateHelper.Create(BaseDate), dataPoints = null }; return(volatilityMatrix); }
public static AdjustableOrAdjustedDate CreateUnadjustedDate(DateTime unadjustedDate) { var date = new AdjustableOrAdjustedDate(); var identifiedDate = IdentifiedDateHelper.Create("UnadjustedDate", unadjustedDate); var items = new object[1]; items[0] = identifiedDate; date.Items = items; var itemsElementName = new ItemsChoiceType[1]; itemsElementName[0] = ItemsChoiceType.unadjustedDate; date.ItemsElementName = itemsElementName; return(date); }
private static TradeHeader CreateTradeHeader(DateTime tradeDate, string tradeId) { var tradeHeader = new TradeHeader { tradeDate = IdentifiedDateHelper.Create(TradeProp.TradeDate, tradeDate), partyTradeIdentifier = new[] { new PartyTradeIdentifier() } }; var tradeIdAsObject = new TradeId { tradeIdScheme = "FpML", Value = tradeId }; XsdClassesFieldResolver.TradeIdentifierSetTradeId(tradeHeader.partyTradeIdentifier[0], tradeIdAsObject); return(tradeHeader); }
/// <summary> /// </summary> /// <param name="fxRates">The spot rate.</param> /// <param name="curveId">The curve id.</param> /// <param name="termCurve">The bootstrapped term curve.</param> /// <returns></returns> private FxCurveValuation CreateEquityCurveValuation(EquityCurveIdentifier curveId, FxRateSet fxRates, TermCurve termCurve) { var fxCurveValuation = new FxCurveValuation { baseDate = IdentifiedDateHelper.Create(curveId.BaseDate), buildDateTime = curveId.BaseDate, buildDateTimeSpecified = true, spotRate = fxRates, id = curveId.UniqueIdentifier, fxForwardCurve = termCurve, spotDate = IdentifiedDateHelper.Create("SettlementDate", SettlementDate), }; return(fxCurveValuation); }
/// <summary> /// Creates the yield curve valuation. /// </summary> /// <param name="curveId"></param> /// <param name="quotedAssetSet">The quoted asset set.</param> /// <param name="commodityurveId">The commodity curve id.</param> /// <param name="forwardCurve">The curve</param> /// <returns></returns> protected static FxCurveValuation CreateCommodiyCurveValuation(PricingStructureIdentifier curveId, FxRateSet quotedAssetSet, string commodityurveId, TermCurve forwardCurve) { var yieldCurveValuation = new FxCurveValuation { baseDate = IdentifiedDateHelper.Create(curveId.BaseDate), buildDateTime = curveId.BuildDateTime, buildDateTimeSpecified = true, spotRate = quotedAssetSet, id = commodityurveId, definitionRef = curveId.PricingStructureType.ToString(), fxForwardCurve = forwardCurve }; return(yieldCurveValuation); }
/// <summary> /// </summary> /// <param name="baseDate">The base date.</param> /// <param name="commodityRates">The spot rate.</param> /// <param name="curveId">The curve id.</param> /// <param name="termCurve">The bootstrapped term curve.</param> /// <returns></returns> private static FxCurveValuation CreateCommodityCurveValuation(DateTime baseDate, FxRateSet commodityRates, string curveId, TermCurve termCurve) { var commodityCurveValuation = new FxCurveValuation { baseDate = IdentifiedDateHelper.Create(baseDate), buildDateTime = baseDate, buildDateTimeSpecified = true, spotRate = commodityRates, id = curveId, fxForwardCurve = termCurve }; return(commodityCurveValuation); }
/// <summary> /// Creates the equity curve. /// </summary> /// <param name="logger">The logger.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">THe client namespace</param> /// <param name="equityId">THe underlying curve asset.</param> /// <param name="fixingCalendar"></param> /// <param name="rollCalendar"></param> /// <param name="baseDate">The base date.</param> /// <param name="fxRates">The spot rate.</param> /// <param name="curveId">The curve id.</param> /// <param name="termCurve">The bootstrapped term curve.</param> /// <returns></returns> private static FxCurveValuation CreateEquityCurveValuation(ILogger logger, ICoreCache cache, string nameSpace, EquityCurveIdentifier equityId, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar, DateTime baseDate, FxRateSet fxRates, string curveId, TermCurve termCurve) { DateTime settlementDate = GetSettlementDate(logger, cache, nameSpace, equityId, fixingCalendar, rollCalendar, baseDate); var fxCurveValuation = new FxCurveValuation { baseDate = IdentifiedDateHelper.Create(baseDate), buildDateTime = baseDate, buildDateTimeSpecified = true, spotRate = fxRates, id = curveId, fxForwardCurve = termCurve, spotDate = IdentifiedDateHelper.Create("SettlementDate", settlementDate) }; return(fxCurveValuation); }
///<summary> ///</summary> public override FpML.V5r3.Reporting.Lease GetLease() { var lease = new FpML.V5r3.Reporting.Lease { currency = new IdentifiedCurrency { Value = Currency.Value, id = "Currency" }, definition = null, description = Description, id = Id, leaseTenor = LeaseTenor, leaseExpiryDate = IdentifiedDateHelper.Create("MaturityDate", MaturityDate), paymentFrequency = Frequency, }; if (InstrumentIds != null) { lease.instrumentId = InstrumentIds.ToArray(); } return(lease); }
public static CalculationPeriodsPrincipalExchangesAndStubs GenerateCalculationPeriodsPrincipalExchangesAndStubs( InterestRateStream interestRateStream, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar) { CalculationPeriodDates calculationPeriodDates = interestRateStream.calculationPeriodDates; AdjustableDate adjustableEffectiveDate = XsdClassesFieldResolver.CalculationPeriodDatesGetEffectiveDate(calculationPeriodDates); AdjustableDate adjustableTerminationDate = XsdClassesFieldResolver.CalculationPeriodDatesGetTerminationDate(calculationPeriodDates); AdjustableDate adjustableFirstPeriodDate = adjustableEffectiveDate; DateTime?firstRegularPeriodStartDate = XsdClassesFieldResolver.CalculationPeriodDatesGetFirstRegularPeriodStartDate(calculationPeriodDates); var tempDate = XsdClassesFieldResolver.CalculationPeriodDatesGetFirstPeriodStartDate(calculationPeriodDates); if (tempDate != null && firstRegularPeriodStartDate != null) { adjustableFirstPeriodDate = tempDate; Frequency frequency = calculationPeriodDates.calculationPeriodFrequency; var startDate = CalculationPeriodGenerator.AddPeriod((DateTime)firstRegularPeriodStartDate, IntervalHelper.FromFrequency(frequency), -1); adjustableFirstPeriodDate.unadjustedDate = IdentifiedDateHelper.Create(startDate); } DateTime?lastRegularPeriodEndDate = XsdClassesFieldResolver.CalculationPeriodDatesGetLastRegularPeriodEndDate(calculationPeriodDates); // This assumes automatic adjustment of calculationperiods. CalculationPeriodsPrincipalExchangesAndStubs result = CalculationPeriodGenerator.GenerateAdjustedCalculationPeriods( adjustableFirstPeriodDate.unadjustedDate.Value, adjustableTerminationDate.unadjustedDate.Value, firstRegularPeriodStartDate, lastRegularPeriodEndDate, calculationPeriodDates.calculationPeriodFrequency, calculationPeriodDates.calculationPeriodDatesAdjustments, paymentCalendar); //Determine whether the reset dates must be calcuated. Calculation calculation = XsdClassesFieldResolver.CalculationPeriodAmountGetCalculation(interestRateStream.calculationPeriodAmount); // Add principle exchanges if this need is defined in parametric representation of the interest rate steam. // if (null != interestRateStream.principalExchanges) { //if (paymentCalendar == null) //{ // paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, adjustableEffectiveDate.dateAdjustments.businessCenters); //} // Initial PE // if (interestRateStream.principalExchanges.initialExchange) { PrincipalExchange initialExchange = PrincipalExchangeHelper.Create(AdjustedDateHelper.ToAdjustedDate(paymentCalendar, adjustableEffectiveDate)); result.InitialPrincipalExchange = initialExchange; } // intermediatory PE // if (interestRateStream.principalExchanges.intermediateExchange) { // Generate a list of intermediatory PE exchanges // Notional notionalSchedule = XsdClassesFieldResolver.CalculationGetNotionalSchedule(calculation); if (null != notionalSchedule.notionalStepSchedule.step)//there should be steps - otherwise NO interm. exchanges. { foreach (DateTime stepDate in ScheduleHelper.GetStepDates(notionalSchedule.notionalStepSchedule)) { PrincipalExchange intermediatoryExchange = PrincipalExchangeHelper.Create(stepDate); result.Add(intermediatoryExchange); } } } // Final PE // Assume the same calendar is used for the termination date as well! if (interestRateStream.principalExchanges.finalExchange) { PrincipalExchange finalExchange = PrincipalExchangeHelper.Create(AdjustedDateHelper.ToAdjustedDate(paymentCalendar, adjustableTerminationDate)); result.FinalPrincipalExchange = finalExchange; } } //Only does upfront resetRelativeTo start date. if (interestRateStream.resetDates != null && calculation.Items[0].GetType() == typeof(FloatingRateCalculation)) { //Get the fixing date convention. var fixingDateConvention = interestRateStream.resetDates.resetDatesAdjustments; //if (fixingCalendar == null) //{ // fixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fixingDateConvention.businessCenters); //} foreach (var calculationPeriod in result.CalculationPeriods) { if (calculationPeriod.adjustedStartDateSpecified) { //Set the adjusted fixing date. var adjustedFixingDate = AdjustedDateHelper.ToAdjustedDate(fixingCalendar, calculationPeriod.adjustedStartDate, fixingDateConvention); var floatingRateDefinition = new FloatingRateDefinition(); var rateObservation = new RateObservation { observedRateSpecified = false, adjustedFixingDateSpecified = true, adjustedFixingDate = adjustedFixingDate }; floatingRateDefinition.rateObservation = new[] { rateObservation }; calculationPeriod.Item1 = floatingRateDefinition; } } //The initial stub period. if (result.InitialStubCalculationPeriod != null) { if (result.InitialStubCalculationPeriod.adjustedStartDateSpecified) { //Set the adjusted fixing date. var adjustedFixingDate = AdjustedDateHelper.ToAdjustedDate(fixingCalendar, result.InitialStubCalculationPeriod.adjustedStartDate, fixingDateConvention); var floatingRateDefinition = new FloatingRateDefinition(); var rateObservation = new RateObservation { observedRateSpecified = false, adjustedFixingDateSpecified = true, adjustedFixingDate = adjustedFixingDate }; floatingRateDefinition.rateObservation = new[] { rateObservation }; result.InitialStubCalculationPeriod.Item1 = floatingRateDefinition; } } //The final stub period if (result.FinalStubCalculationPeriod != null) { if (result.FinalStubCalculationPeriod.adjustedStartDateSpecified) { //Set the adjusted fixing date. var adjustedFixingDate = AdjustedDateHelper.ToAdjustedDate(fixingCalendar, result.FinalStubCalculationPeriod.adjustedStartDate, fixingDateConvention); var floatingRateDefinition = new FloatingRateDefinition(); var rateObservation = new RateObservation { observedRateSpecified = false, adjustedFixingDateSpecified = true, adjustedFixingDate = adjustedFixingDate }; floatingRateDefinition.rateObservation = new[] { rateObservation }; result.FinalStubCalculationPeriod.Item1 = floatingRateDefinition; } } } return(result); }