示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        /// <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);
        }
示例#6
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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }