public static RateIndex Parse(string id, string instrumentId, string floatingRateIndex, string currency, string dayCountFraction, string paymentFrequency, string term) { var rateIndex = new RateIndex { currency = new IdentifiedCurrency { Value = currency }, dayCountFraction = DayCountFractionHelper.Parse(dayCountFraction), floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex), id = id, instrumentId = InstrumentIdArrayHelper.Parse(instrumentId) }; Period frequency = null; if (paymentFrequency != null) { frequency = PeriodHelper.Parse(paymentFrequency); } rateIndex.paymentFrequency = frequency; Period period = null; if (term != null) { period = PeriodHelper.Parse(term); } rateIndex.term = period; return(rateIndex); }
public static FloatingRateCalculation Create(string floatingRateIndex, string indexTenor, decimal spreadInitialValue) { var result = new FloatingRateCalculation { floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex), indexTenor = PeriodHelper.Parse(indexTenor), spreadSchedule = new[] { SpreadScheduleFactory.Create(spreadInitialValue) } }; return(result); }
public static Trade CreateFraTrade(FraInputRange2 fraInputRange) { var trade = new Trade(); var fra = new Fra { adjustedEffectiveDate = DateTypesHelper.ToRequiredIdentifierDate(fraInputRange.AdjustedEffectiveDate), adjustedTerminationDate = fraInputRange.AdjustedTerminationDate, adjustedTerminationDateSpecified = true, paymentDate = DateTypesHelper.ToAdjustableDate(fraInputRange.UnadjustedPaymentDate, fraInputRange.PaymentDateBusinessDayConvention, fraInputRange.PaymentDateBusinessCenters), Items = new object[] { new ProductType { Value = ProductTypeSimpleEnum.FRA.ToString() } }, ItemsElementName = new[] { ItemsChoiceType2.productType } }; if ("resetDate" != fraInputRange.FixingDayOffsetDateRelativeTo) { throw new ArgumentException("The fixing date must be specified as 'resetDate'-relative!", nameof(fraInputRange)); } var fixingDayType = EnumHelper.Parse <DayTypeEnum>(fraInputRange.FixingDayOffsetDayType); fra.fixingDateOffset = RelativeDateOffsetHelper.Create(fraInputRange.FixingDayOffsetPeriod, fixingDayType, fraInputRange.FixingDayOffsetBusinessDayConvention, fraInputRange.FixingDayOffsetBusinessCenters, fraInputRange.FixingDayOffsetDateRelativeTo); fra.dayCountFraction = DayCountFractionHelper.Parse(fraInputRange.DayCountFraction); IDayCounter dayCounter = DayCounterHelper.Parse(fra.dayCountFraction.Value); fra.calculationPeriodNumberOfDays = dayCounter.DayCount(fra.adjustedEffectiveDate.Value, fra.adjustedTerminationDate).ToString(CultureInfo.InvariantCulture); fra.notional = MoneyHelper.GetAmount(fraInputRange.NotionalAmount, fraInputRange.NotionalCurrency); fra.fixedRate = (decimal)fraInputRange.FixedRate; fra.fixedRateSpecified = true; fra.floatingRateIndex = FloatingRateIndexHelper.Parse(fraInputRange.FloatingRateIndex); fra.indexTenor = new[] { PeriodHelper.Parse(fraInputRange.IndexTenor) }; fra.fraDiscounting = fraInputRange.FraDiscounting; fra.fraDiscountingSpecified = true; PartyReference party1 = PartyReferenceFactory.Create("party1"); PartyReference party2 = PartyReferenceFactory.Create("party2"); fra.sellerPartyReference = party1; fra.buyerPartyReference = party2; if (bool.Parse(fraInputRange.IsParty1Buyer)) { fra.sellerPartyReference = party2; fra.buyerPartyReference = party1; } XsdClassesFieldResolver.TradeSetFra(trade, fra); trade.id = fraInputRange.TradeId; return(trade); }
public static RateIndex Parse(string floatingRateIndex, string currency, string dayCountFraction) { var rateIndex = new RateIndex { currency = new IdentifiedCurrency { Value = currency }, dayCountFraction = DayCountFractionHelper.Parse(dayCountFraction), floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex), }; return(rateIndex); }
/// <summary> /// /// </summary> /// <param name="fraInputRange"></param> /// <returns></returns> public static Fra GetFpMLFra(FraInputRange fraInputRange) { var fra = new Fra { adjustedEffectiveDate = DateTypesHelper.ToRequiredIdentifierDate(fraInputRange.AdjustedEffectiveDate), adjustedTerminationDate = fraInputRange.AdjustedTerminationDate, paymentDate = DateTypesHelper.ToAdjustableDate(fraInputRange.UnadjustedPaymentDate, fraInputRange.PaymentDateBusinessDayConvention, fraInputRange.PaymentDateBusinessCenters) }; if ("resetDate" != fraInputRange.FixingDayOffsetDateRelativeTo) { throw new ArgumentException("The fixing date must be specified as 'resetDate'-relative!", nameof(fraInputRange)); } var fixingDayType = EnumHelper.Parse <DayTypeEnum>(fraInputRange.FixingDayOffsetDayType); fra.fixingDateOffset = RelativeDateOffsetHelper.Create(fraInputRange.FixingDayOffsetPeriod, fixingDayType, fraInputRange.FixingDayOffsetBusinessDayConvention, fraInputRange.FixingDayOffsetBusinessCenters, fraInputRange.FixingDayOffsetDateRelativeTo); fra.dayCountFraction = DayCountFractionHelper.Parse(fraInputRange.DayCountFraction); IDayCounter dayCounter = DayCounterHelper.Parse(fra.dayCountFraction.Value); fra.calculationPeriodNumberOfDays = dayCounter.DayCount(fra.adjustedEffectiveDate.Value, fra.adjustedTerminationDate).ToString(); fra.notional = MoneyHelper.GetAmount(fraInputRange.NotionalAmount, fraInputRange.NotionalCurrency); fra.fixedRate = (decimal)fraInputRange.FixedRate; fra.floatingRateIndex = FloatingRateIndexHelper.Parse(fraInputRange.FloatingRateIndex); fra.indexTenor = new[] { PeriodHelper.Parse(fraInputRange.IndexTenor) }; fra.fraDiscounting = fraInputRange.FraDiscounting; PartyReference nabParty = PartyReferenceFactory.Create("NAB"); PartyReference counterParty = PartyReferenceFactory.Create("COUNTERPARTY"); if (bool.Parse(fraInputRange.Sell)) { fra.sellerPartyReference = nabParty; fra.buyerPartyReference = counterParty; } else { fra.sellerPartyReference = counterParty; fra.buyerPartyReference = nabParty; } return(fra); }
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); }
public static RateIndex Parse(string floatingRateIndex, string currency, string dayCountFraction, string term) { var rateIndex = new RateIndex { currency = new IdentifiedCurrency { Value = currency }, dayCountFraction = DayCountFractionHelper.Parse(dayCountFraction), floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex), }; Period period = null; if (term != null) { period = PeriodHelper.Parse(term); } rateIndex.term = period; return(rateIndex); }
public static RateIndex Parse(string instrumentId, string floatingRateIndex, string currency, string dayCountFraction, string paymentFrequency, string term) { var rateIndex = new RateIndex { currency = new IdentifiedCurrency { Value = currency }, dayCountFraction = DayCountFractionHelper.Parse(dayCountFraction), floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex), id = instrumentId, instrumentId = InstrumentIdArrayHelper.Parse(instrumentId), paymentFrequency = PeriodHelper.Parse(paymentFrequency), term = PeriodHelper.Parse(term) }; return(rateIndex); }