/// <summary> /// /// </summary> /// <param name="leg1Parameters"></param> /// <param name="leg2Parameters"></param> /// <returns></returns> public static Swap GenerateDefiniton( SwapLegParametersRange leg1Parameters, SwapLegParametersRange leg2Parameters) { InterestRateStream stream1 = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(leg1Parameters); InterestRateStreamHelper.SetPayerAndReceiver(stream1, leg1Parameters.Payer, leg1Parameters.Receiver); InterestRateStream stream2 = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(leg2Parameters); InterestRateStreamHelper.SetPayerAndReceiver(stream2, leg2Parameters.Payer, leg2Parameters.Receiver); return(SwapFactory.Create(stream1, stream2)); }
internal static Pair <ValuationResultRange, Swap> GetPriceAndGeneratedFpMLSwap( ILogger logger, ICoreCache cache, String nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, ValuationRange valuationRange, TradeRange tradeRange, SwapLegParametersRange_Old leg1ParametersRange, List <DetailedCashflowRangeItem> leg1DetailedCashflowsList, List <PrincipalExchangeCashflowRangeItem> leg1PrincipalExchangeCashflowList, List <AdditionalPaymentRangeItem> leg1AdditionalPaymentList) { InterestRateStream stream1 = GetCashflowsSchedule(fixingCalendar, paymentCalendar, leg1ParametersRange);//parametric definiton + cashflows schedule var swap = SwapFactory.Create(stream1); // Update FpML cashflows // UpdateCashflowsWithDetailedCashflows(stream1.cashflows, leg1DetailedCashflowsList); // Update PE // if (null != leg1PrincipalExchangeCashflowList) { CreatePrincipalExchangesFromListOfRanges(stream1.cashflows, leg1PrincipalExchangeCashflowList); } // Add bullet payments... // if (null != leg1AdditionalPaymentList) { swap.additionalPayment = leg1AdditionalPaymentList.Select(bulletPaymentRangeItem => new Payment { payerPartyReference = PartyReferenceFactory.Create(leg1ParametersRange.Payer), receiverPartyReference = PartyReferenceFactory.Create(leg1ParametersRange.Receiver), paymentAmount = MoneyHelper.GetNonNegativeAmount(bulletPaymentRangeItem.Amount), paymentDate = DateTypesHelper.ToAdjustableOrAdjustedDate(bulletPaymentRangeItem.PaymentDate) }).ToArray(); } // Update FpML cashflows with DF,FV,PV, etc (LegParametersRange needed to access curve functionality) // UpdateCashflowsWithAmounts(logger, cache, nameSpace, stream1, leg1ParametersRange, valuationRange); // Update additional payments // var leg1DiscountCurve = CurveLoader.LoadInterestRateCurve(logger, cache, nameSpace, leg1ParametersRange.DiscountCurve); SwapGenerator.UpdatePaymentsAmounts(logger, cache, nameSpace, swap, leg1ParametersRange, leg1DiscountCurve, valuationRange.ValuationDate, paymentCalendar); //~ Update additional payments string baseParty = valuationRange.BaseParty; return(new Pair <ValuationResultRange, Swap>(CreateValuationRange(swap, baseParty), swap)); }
internal static ValuationResultRange GetPriceOld( ILogger logger, ICoreCache cache, String nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, SwapLegParametersRange_Old leg1ParametersRange, SwapLegParametersRange_Old leg2ParametersRange, ValuationRange valuationRange) { string baseParty = valuationRange.BaseParty; InterestRateStream stream1 = GetCashflowsSchedule(fixingCalendar, paymentCalendar, leg1ParametersRange); //pay leg InterestRateStream stream2 = GetCashflowsSchedule(fixingCalendar, paymentCalendar, leg2ParametersRange); //receive leg var swap = SwapFactory.Create(stream1, stream2); UpdateCashflowsWithAmounts(logger, cache, nameSpace, stream1, leg1ParametersRange, valuationRange); UpdateCashflowsWithAmounts(logger, cache, nameSpace, stream2, leg2ParametersRange, valuationRange); ValuationResultRange resultRange = CreateValuationRange(swap, baseParty); return(resultRange); }