/// <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)); }
public void SetCalibrationDate(Date calibrationDate) { _floatLeg = SwapFactory.CreateFloatLeg(calibrationDate, _tenor, _index, _spread); _fixedLeg = SwapFactory.CreateFixedLeg(calibrationDate, _tenor, _index, _fixedRate); _floatLeg.SetValueDate(calibrationDate); _fixedLeg.SetValueDate(calibrationDate); _endDate = _floatLeg.GetCashflowDates(_index.Currency).Max(); var otherEndDate = _fixedLeg.GetCashflowDates(_index.Currency).Max(); if (_endDate < otherEndDate) { _endDate = otherEndDate; } }
public void SetCalibrationDate(Date calibrationDate) { _leg1 = SwapFactory.CreateFloatLeg(calibrationDate, _tenor, _leg1Index, _leg1Spread); _leg2 = SwapFactory.CreateFloatLeg(calibrationDate, _tenor, _leg2Index, _leg2Spread); _leg1.SetValueDate(calibrationDate); _leg2.SetValueDate(calibrationDate); _endDate = _leg1.GetCashflowDates(_leg1Index.Currency).Max(); var otherEndDate = _leg2.GetCashflowDates(_leg2Index.Currency).Max(); if (_endDate < otherEndDate) { _endDate = otherEndDate; } }
public static IRSwap CreateZARSwap([ExcelArgument(Description = "First reset date of the swap")] Date startDate, [ExcelArgument(Description = "Tenor of swap, must be a whole number of years. Example '5Y'.")] Tenor tenor, [ExcelArgument(Description = "The fixed rate paid or received")] double rate, [ExcelArgument(Description = "Is the fixed rate paid? Enter 'TRUE' for yes.")] bool payFixed, [ExcelArgument(Description = "Flat notional for all dates.")] double notional, [QuantSAExcelArgument(Description = "The float rate index of the swap.", Default = "DEFAULT")] FloatRateIndex jibar) { return(SwapFactory.CreateZARSwap(rate, payFixed, notional, startDate, tenor, jibar)); }
public static BermudanSwaption CreateZARBermudanSwaption( [ExcelArgument(Description = "The exercise dates. The dates on which the person who is long optionality can exercise.")] Date[] exerciseDates, [ExcelArgument(Description = "if set to TRUE then the person valuing this product owns the optionality.")] bool longOptionality, [ExcelArgument(Description = "First reset date of the underlying swap.")] Date startDate, [ExcelArgument(Description = "Tenor of underlying swap, must be a whole number of years. Example '5Y'.")] Tenor tenor, [ExcelArgument(Description = "The fixed rate paid or received on the underlying swap.")] double rate, [ExcelArgument(Description = "Is the fixed rate paid? Enter 'TRUE' for yes.")] bool payFixed, [ExcelArgument(Description = "Flat notional for all dates.")] double notional, [QuantSAExcelArgument(Description = "Flat notional for all dates.", Default = "DEFAULT")] FloatRateIndex jibar) { return(SwapFactory.CreateZARBermudanSwaption(exerciseDates, longOptionality, rate, payFixed, notional, startDate, tenor, jibar)); }
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); }