예제 #1
0
        public string CreateValuation(
            ILogger logger, ICoreCache cache,
            String nameSpace,
            IBusinessCalendar fixingCalendar,
            IBusinessCalendar paymentCalendar,
            List <StringObjectRangeItem> valuationSet,
            ValuationRange valuationRange,
            TradeRange tradeRange,
            CapFloorLegParametersRange_Old legParametersRange,
            List <InputCashflowRangeItem> legDetailedCashflowsListArray,
            List <InputPrincipalExchangeCashflowRangeItem> legPrincipleExchangeCashflowListArray,
            List <AdditionalPaymentRangeItem> legAdditionalPaymentListArray,
            List <PartyIdRangeItem> partyIdList,                     //optional
            List <OtherPartyPaymentRangeItem> otherPartyPaymentList, //optional
            List <FeePaymentRangeItem> feePaymentList                //optional
            )
        {
            Pair <ValuationResultRange, CapFloor> fpML = GetPriceAndGeneratedFpML(logger, cache, nameSpace, fixingCalendar, paymentCalendar, valuationRange, tradeRange,
                                                                                  legParametersRange, legDetailedCashflowsListArray, legPrincipleExchangeCashflowListArray,
                                                                                  legAdditionalPaymentListArray, feePaymentList);
            CapFloor capFloor = fpML.Second;
            string   valuationReportAndProductId = tradeRange.Id ?? Guid.NewGuid().ToString();

            capFloor.id = valuationReportAndProductId;
            AssetValuation assetValuation = InterestRateProduct.CreateAssetValuationFromValuationSet(valuationSet);
            //Valuation valuation = new Valuation();
            //  TODO: add Trade Id & Trade data into valuation. (Trade.Id & Trade.TradeHeader.TradeDate)
            //
            string baseParty    = valuationRange.BaseParty;
            var    uniqueCurves = new List <IRateCurve>();

            foreach (string curveName in new[] { legParametersRange.ForecastCurve, legParametersRange.DiscountCurve })
            {
                if (!String.IsNullOrEmpty(curveName))
                {
                    var curve = CurveLoader.LoadInterestRateCurve(logger, cache, nameSpace, curveName);
                    if (!uniqueCurves.Contains(curve))
                    {
                        uniqueCurves.Add(curve);
                    }
                }
            }
            Market          fpMLMarket      = InterestRateProduct.CreateFpMLMarketFromCurves(uniqueCurves);
            ValuationReport valuationReport = ValuationReportGenerator.Generate(valuationReportAndProductId, baseParty, valuationReportAndProductId, tradeRange.TradeDate, capFloor, fpMLMarket, assetValuation);

            cache.SaveObject(valuationReport, valuationReportAndProductId, null);
            InterestRateProduct.ReplacePartiesInValuationReport(valuationReport, partyIdList);
            InterestRateProduct.AddOtherPartyPayments(valuationReport, otherPartyPaymentList);
            return(valuationReportAndProductId);
        }
예제 #2
0
        public string CreateValuation(
            ILogger logger,
            ICoreCache cache,
            String nameSpace,
            IBusinessCalendar fixingCalendar,
            IBusinessCalendar paymentCalendar,
            List <StringObjectRangeItem> valuationSet,
            ValuationRange valuationRange,
            TradeRange tradeRange,
            SwapLegParametersRange_Old leg1ParametersRange,
            List <DetailedCashflowRangeItem> leg1DetailedCashflowsListArray,
            List <PrincipalExchangeCashflowRangeItem> leg1PrincipalExchangeCashflowListArray,
            List <AdditionalPaymentRangeItem> leg1AdditionalPaymentListArray,
            List <PartyIdRangeItem> partyIdList,//optional
            List <OtherPartyPaymentRangeItem> otherPartyPaymentList
            )
        {
            Swap   floater   = GetPriceAndGeneratedFpMLSwap(logger, cache, nameSpace, fixingCalendar, paymentCalendar, valuationRange, tradeRange, leg1ParametersRange, leg1DetailedCashflowsListArray, leg1PrincipalExchangeCashflowListArray, leg1AdditionalPaymentListArray).Second;
            string baseParty = valuationRange.BaseParty;
            string valuationReportAndProductId = tradeRange.Id ?? Guid.NewGuid().ToString();

            floater.id = valuationReportAndProductId;
            var    uniqueCurves = GetUniqueCurves(logger, cache, nameSpace, leg1ParametersRange);
            Market fpMLMarket   = InterestRateProduct.CreateFpMLMarketFromCurves(uniqueCurves);
            var    valuation    = new Valuations.Valuation();
            //  TODO: add Trade Id & Trade data into valuation. (Trade.Id & Trade.TradeHeader.TradeDate)
            //
            AssetValuation assetValuation = InterestRateProduct.CreateAssetValuationFromValuationSet(valuationSet);

            valuation.CreateSwapValuationReport(cache, nameSpace, valuationReportAndProductId, baseParty, tradeRange.Id, tradeRange.TradeDate, floater, fpMLMarket, assetValuation);
            ValuationReport valuationReport = valuation.Get(cache, nameSpace, valuationReportAndProductId);

            InterestRateProduct.ReplacePartiesInValuationReport(valuationReport, partyIdList);
            InterestRateProduct.AddOtherPartyPayments(valuationReport, otherPartyPaymentList);

            return(valuationReportAndProductId);
        }
예제 #3
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);
        }