示例#1
0
        /// <summary>
        /// Builds this instance and retruns the underlying instrument associated with the controller
        /// </summary>
        /// <returns></returns>
        public Swaption Build()
        {
            var premium  = MapToPayments(PremiumPayments); //MoneyHelper.GetAmount(Premium, PremiumCurrency);
            var swaption = SwaptionFactory.Create(Swap.Build(), premium, Exercise, AutomaticExcercise);

            return(swaption);
        }
        public static Swaption GenerateSwaptionDefiniton(SwapLegParametersRange_Old leg1Parameters,
                                                         IBusinessCalendar leg1PaymentCalendar,
                                                         SwapLegParametersRange_Old leg2Parameters,
                                                         IBusinessCalendar leg2PaymentCalendar,
                                                         SwaptionParametersRange swaptionParameters)
        {
            Swap                     swap           = SwapGenerator.GenerateDefiniton(leg1Parameters, leg2Parameters);
            NonNegativeMoney         premium        = MoneyHelper.GetNonNegativeAmount(swaptionParameters.Premium, swaptionParameters.PremiumCurrency);
            AdjustableDate           expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParameters.ExpirationDate, swaptionParameters.ExpirationDateBusinessDayAdjustments, swaptionParameters.ExpirationDateCalendar);
            AdjustableOrAdjustedDate paymentDate    = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParameters.PaymentDate, swaptionParameters.PaymentDateBusinessDayAdjustments, swaptionParameters.PaymentDateCalendar);
            TimeSpan                 earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParameters.EarliestExerciseTime);
            DateTime                 earliestExerciseTime           = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan);
            TimeSpan                 expirationTimeAsTimeSpan       = TimeSpan.FromDays(swaptionParameters.ExpirationTime);
            DateTime                 expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan);

            return(SwaptionFactory.Create(swap, premium,
                                          swaptionParameters.PremiumPayer, swaptionParameters.PremiumReceiver,
                                          paymentDate, expirationDate,
                                          earliestExerciseTime, expirationTime, swaptionParameters.AutomaticExcercise));
        }
示例#3
0
        public static Trade CreateSwaptionTrade(SwaptionParametersRange swaptionParametersRange, IBusinessCalendar paymentCalendar, Swap underlyingSwap)
        {
            var                      premium        = MoneyHelper.GetNonNegativeAmount(swaptionParametersRange.Premium, swaptionParametersRange.PremiumCurrency);
            AdjustableDate           expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParametersRange.ExpirationDate, swaptionParametersRange.ExpirationDateBusinessDayAdjustments, swaptionParametersRange.ExpirationDateCalendar);
            AdjustableOrAdjustedDate paymentDate    = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParametersRange.PaymentDate, swaptionParametersRange.PaymentDateBusinessDayAdjustments, swaptionParametersRange.PaymentDateCalendar);
            TimeSpan                 earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.EarliestExerciseTime);
            DateTime                 earliestExerciseTime           = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan);
            TimeSpan                 expirationTimeAsTimeSpan       = TimeSpan.FromDays(swaptionParametersRange.ExpirationTime);
            DateTime                 expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan);
            var                      swaption       = SwaptionFactory.Create(underlyingSwap, premium, swaptionParametersRange.PremiumPayer, swaptionParametersRange.PremiumReceiver,
                                                                             paymentDate, expirationDate,
                                                                             earliestExerciseTime, expirationTime, swaptionParametersRange.AutomaticExcercise);

            swaption.Items = new object[] { new ProductType {
                                                Value = ProductTypeSimpleEnum.InterestRateSwaption.ToString()
                                            } };
            swaption.ItemsElementName = new[] { ItemsChoiceType2.productType };
            var trade = new Trade();

            XsdClassesFieldResolver.TradeSetSwaption(trade, swaption);
            return(trade);
        }
示例#4
0
        public string CreateValuation(
            ILogger logger,
            ICoreCache cache,
            String nameSpace,
            IBusinessCalendar fixingCalendar,
            IBusinessCalendar paymentCalendar,
            SwaptionParametersRange swaptionParametersRange,
            List <StringObjectRangeItem> valuationSet,
            ValuationRange valuationRange,
            TradeRange tradeRange,
            SwapLegParametersRange leg1ParametersRange,
            SwapLegParametersRange leg2ParametersRange,
            List <InputCashflowRangeItem> leg1DetailedCashflowsListArray,
            List <InputCashflowRangeItem> leg2DetailedCashflowsListArray,
            List <InputPrincipalExchangeCashflowRangeItem> leg1PrincipalExchangeCashflowListArray,
            List <InputPrincipalExchangeCashflowRangeItem> leg2PrincipalExchangeCashflowListArray,
            List <AdditionalPaymentRangeItem> leg1AdditionalPaymentListArray,
            List <AdditionalPaymentRangeItem> leg2AdditionalPaymentListArray,
            List <PartyIdRangeItem> partyIdList,                     //optional
            List <OtherPartyPaymentRangeItem> otherPartyPaymentList, //opt
            List <FeePaymentRangeItem> feePaymentList                //opt
            )
        {
            var swap = GetPriceAndGeneratedFpMLSwap(logger, cache, nameSpace,
                                                    fixingCalendar, paymentCalendar, valuationRange,
                                                    tradeRange, leg1ParametersRange, leg2ParametersRange,
                                                    leg1DetailedCashflowsListArray, leg2DetailedCashflowsListArray,
                                                    leg1PrincipalExchangeCashflowListArray, leg2PrincipalExchangeCashflowListArray,
                                                    leg1AdditionalPaymentListArray, leg2AdditionalPaymentListArray).Second;
            string            baseParty    = valuationRange.BaseParty;
            List <IRateCurve> uniqueCurves = GetUniqueCurves(logger, cache, nameSpace, leg1ParametersRange, leg2ParametersRange);
            Market            fpMLMarket   = InterestRateProduct.CreateFpMLMarketFromCurves(uniqueCurves);
            //  TODO: add Trade Id & Trade data into valuation. (Trade.Id & Trade.TradeHeader.TradeDate)
            //
            //  create ValuationReport and add it to in-memory collection.
            //  Add methods!
            AssetValuation           assetValuation = InterestRateProduct.CreateAssetValuationFromValuationSet(valuationSet);
            NonNegativeMoney         premium        = MoneyHelper.GetNonNegativeAmount(swaptionParametersRange.Premium, swaptionParametersRange.PremiumCurrency);
            AdjustableDate           expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParametersRange.ExpirationDate, swaptionParametersRange.ExpirationDateBusinessDayAdjustments, swaptionParametersRange.ExpirationDateCalendar);
            AdjustableOrAdjustedDate paymentDate    = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParametersRange.PaymentDate, swaptionParametersRange.PaymentDateBusinessDayAdjustments, swaptionParametersRange.PaymentDateCalendar);
            TimeSpan earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.EarliestExerciseTime);
            DateTime earliestExerciseTime           = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan);
            TimeSpan expirationTimeAsTimeSpan       = TimeSpan.FromDays(swaptionParametersRange.ExpirationTime);
            DateTime expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan);
            var      swaption       = SwaptionFactory.Create(swap, premium, swaptionParametersRange.PremiumPayer, swaptionParametersRange.PremiumReceiver,
                                                             paymentDate, expirationDate,
                                                             earliestExerciseTime, expirationTime, swaptionParametersRange.AutomaticExcercise);
            // overrides the premium created by SwaptionFactort.Create
            //
            var feeList = new List <Payment>();

            if (null != feePaymentList)
            {
                feeList.AddRange(feePaymentList.Select(feePaymentRangeItem => new Payment
                {
                    paymentDate            = DateTypesHelper.ToAdjustableOrAdjustedDate(feePaymentRangeItem.PaymentDate),
                    paymentAmount          = MoneyHelper.GetNonNegativeAmount(feePaymentRangeItem.Amount),
                    payerPartyReference    = PartyReferenceFactory.Create(feePaymentRangeItem.Payer),
                    receiverPartyReference = PartyReferenceFactory.Create(feePaymentRangeItem.Receiver)
                }));
            }
            swaption.premium = feeList.ToArray();
            string valuationReportAndProductId = tradeRange.Id ?? Guid.NewGuid().ToString();

            swaption.id = valuationReportAndProductId;
            ValuationReport valuationReport = ValuationReportGenerator.Generate(valuationReportAndProductId, baseParty, valuationReportAndProductId, tradeRange.TradeDate, swaption, fpMLMarket, assetValuation);

            cache.SaveObject(valuationReport, valuationReportAndProductId, null);
            InterestRateProduct.ReplacePartiesInValuationReport(valuationReport, partyIdList);
            InterestRateProduct.AddOtherPartyPayments(valuationReport, otherPartyPaymentList);
            return(valuationReportAndProductId);
        }