public IrSwap(DateTime startDate, Frequency swapTenor, FloatRateIndex rateIndex, double parRate, SwapPayReceiveType swapType, string forecastCurve, string discountCurve) { SwapTenor = swapTenor; ResetFrequency = rateIndex.ResetTenor; StartDate = startDate; EndDate = StartDate.AddPeriod(rateIndex.RollConvention, rateIndex.HolidayCalendars, SwapTenor); ParRate = parRate; BasisFloat = rateIndex.DayCountBasis; BasisFixed = rateIndex.DayCountBasisFixed; SwapType = swapType; FixedLeg = new GenericSwapLeg(StartDate, swapTenor, rateIndex.HolidayCalendars, rateIndex.Currency, ResetFrequency, BasisFixed) { FixedRateOrMargin = (decimal)parRate, LegType = SwapLegType.Fixed, Nominal = 1e6M * (swapType == SwapPayReceiveType.Payer ? -1.0M : 1.0M) }; FloatLeg = new GenericSwapLeg(StartDate, swapTenor, rateIndex.HolidayCalendars, rateIndex.Currency, ResetFrequency, BasisFloat) { FixedRateOrMargin = 0.0M, LegType = SwapLegType.Float, Nominal = 1e6M * (swapType == SwapPayReceiveType.Payer ? 1.0M : -1.0M) }; FlowScheduleFixed = FixedLeg.GenerateSchedule(); FlowScheduleFloat = FloatLeg.GenerateSchedule(); ResetDates = FlowScheduleFloat.Flows.Select(x => x.FixingDateStart).ToArray(); ForecastCurve = forecastCurve; DiscountCurve = discountCurve; }
public ForwardRateAgreement(DateTime startDate, double parRate, FloatRateIndex rateIndex, SwapPayReceiveType payRec, FraDiscountingType fraType, string forecastCurve, string discountCurve) { StartDate = startDate; ResetDate = StartDate.AddPeriod(RollType.P, rateIndex.HolidayCalendars, rateIndex.FixingOffset); EndDate = new TenorDateRelative(rateIndex.ResetTenor); RateIndex = rateIndex; ParRate = parRate; Basis = rateIndex.DayCountBasis; PayRec = payRec; FraLeg = new GenericSwapLeg(StartDate, EndDate.Date(StartDate, rateIndex.RollConvention, rateIndex.HolidayCalendars), rateIndex.HolidayCalendars, rateIndex.Currency, rateIndex.ResetTenor, Basis) { FixedRateOrMargin = (decimal)ParRate }; FlowScheduleFra = FraLeg.GenerateSchedule(); FraLeg.FixedRateOrMargin = (decimal)ParRate; FraLeg.LegType = SwapLegType.Fra; FlowScheduleFra.Flows[0].SettleDate = StartDate; ForecastCurve = forecastCurve; DiscountCurve = discountCurve; FraType = fraType; PillarDate = FlowScheduleFra.Flows[0].AccrualPeriodEnd; }
public ForwardRateAgreement(DateTime valDate, string fraCode, double parRate, FloatRateIndex rateIndex, SwapPayReceiveType payRec, FraDiscountingType fraType, string forecastCurve, string discountCurve) { var code = fraCode.ToUpper().Split('X'); StartDate = valDate.AddPeriod(rateIndex.RollConvention, rateIndex.HolidayCalendars, new Frequency(code[0] + "M")); ResetDate = StartDate.AddPeriod(RollType.P, rateIndex.HolidayCalendars, rateIndex.FixingOffset); EndDate = new TenorDateRelative(rateIndex.ResetTenor); ParRate = parRate; Basis = rateIndex.DayCountBasis; PayRec = payRec; FraLeg = new GenericSwapLeg(StartDate, EndDate.Date(StartDate, rateIndex.RollConvention, rateIndex.HolidayCalendars), rateIndex.HolidayCalendars, rateIndex.Currency, rateIndex.ResetTenor, Basis) { FixedRateOrMargin = (decimal)ParRate }; FlowScheduleFra = FraLeg.GenerateSchedule(); FraLeg.FixedRateOrMargin = (decimal)ParRate; FraLeg.LegType = SwapLegType.Fra; FlowScheduleFra.Flows[0].SettleDate = StartDate; ForecastCurve = forecastCurve; DiscountCurve = discountCurve; FraType = fraType; }
public XccyBasisSwap(DateTime startDate, Frequency swapTenor, double parSpread, bool spreadOnPayLeg, FloatRateIndex payIndex, FloatRateIndex recIndex, ExchangeType notionalExchange, MTMSwapType mtmSwapType, string forecastCurvePay, string forecastCurveRec, string discountCurvePay, string discountCurveRec) { SwapTenor = swapTenor; NotionalExchange = notionalExchange; MtmSwapType = mtmSwapType; RateIndexPay = payIndex; RateIndexRec = recIndex; ResetFrequencyRec = recIndex.ResetTenor; ResetFrequencyPay = payIndex.ResetTenor; StartDate = startDate; EndDate = StartDate.AddPeriod(payIndex.RollConvention, payIndex.HolidayCalendars, SwapTenor); ParSpreadPay = spreadOnPayLeg ? parSpread : 0.0; ParSpreadRec = spreadOnPayLeg ? 0.0 : parSpread; BasisPay = payIndex.DayCountBasis; BasisRec = recIndex.DayCountBasis; CcyPay = payIndex.Currency; CcyRec = recIndex.Currency; PayLeg = new GenericSwapLeg(StartDate, swapTenor, payIndex.HolidayCalendars, payIndex.Currency, ResetFrequencyPay, BasisPay) { FixedRateOrMargin = (decimal)ParSpreadPay, NotionalExchange = NotionalExchange, Direction = SwapPayReceiveType.Payer, LegType = SwapLegType.Float }; RecLeg = new GenericSwapLeg(StartDate, swapTenor, recIndex.HolidayCalendars, recIndex.Currency, ResetFrequencyRec, BasisRec) { FixedRateOrMargin = (decimal)ParSpreadRec, NotionalExchange = NotionalExchange }; PayLeg.Direction = SwapPayReceiveType.Receiver; RecLeg.LegType = SwapLegType.Float; FlowSchedulePay = PayLeg.GenerateSchedule(); FlowScheduleRec = RecLeg.GenerateSchedule(); ResetDates = FlowSchedulePay.Flows.Select(x => x.FixingDateStart) .Union(FlowScheduleRec.Flows.Select(y => y.FixingDateStart)) .Distinct() .OrderBy(x => x) .ToArray(); ForecastCurvePay = forecastCurvePay; ForecastCurveRec = forecastCurveRec; DiscountCurvePay = discountCurvePay; DiscountCurveRec = discountCurveRec; }
public IrBasisSwap(DateTime startDate, Frequency swapTenor, double parSpread, bool spreadOnPayLeg, FloatRateIndex payIndex, FloatRateIndex recIndex, string forecastCurvePay, string forecastCurveRec, string discountCurve, decimal?notional = null) : base() { SwapTenor = swapTenor; ResetFrequencyRec = recIndex.ResetTenor; ResetFrequencyPay = payIndex.ResetTenor; PayIndex = payIndex; RecIndex = recIndex; StartDate = startDate; EndDate = StartDate.AddPeriod(payIndex.RollConvention, payIndex.HolidayCalendars, SwapTenor); ParSpreadPay = spreadOnPayLeg ? parSpread : 0.0; ParSpreadRec = spreadOnPayLeg ? 0.0 : parSpread; BasisPay = payIndex.DayCountBasis; BasisRec = recIndex.DayCountBasis; Notional = (double)(notional ?? 1e6M); PayLeg = new GenericSwapLeg(StartDate, swapTenor, payIndex.HolidayCalendars, payIndex.Currency, ResetFrequencyPay, BasisPay) { FixedRateOrMargin = (decimal)ParSpreadPay, LegType = SwapLegType.Float, Nominal = -(notional ?? 1e6M), AccrualDCB = payIndex.DayCountBasis }; RecLeg = new GenericSwapLeg(StartDate, swapTenor, recIndex.HolidayCalendars, recIndex.Currency, ResetFrequencyRec, BasisRec) { FixedRateOrMargin = (decimal)ParSpreadRec, LegType = SwapLegType.Float, Nominal = notional ?? 1e6M, AccrualDCB = recIndex.DayCountBasis }; FlowSchedulePay = PayLeg.GenerateSchedule(); FlowScheduleRec = RecLeg.GenerateSchedule(); ResetDates = FlowSchedulePay.Flows.Select(x => x.FixingDateStart) .Union(FlowScheduleRec.Flows.Select(y => y.FixingDateStart)) .Distinct() .OrderBy(x => x) .ToArray(); ForecastCurvePay = forecastCurvePay; ForecastCurveRec = forecastCurveRec; DiscountCurve = discountCurve; }
public FloatingRateLoanDepo(DateTime startDate, Frequency tenor, FloatRateIndex floatRateIndex, double notional, double spread, string forecastCurve, string discountCurve) { var leg = new GenericSwapLeg(startDate, tenor, floatRateIndex.HolidayCalendars, floatRateIndex.Currency, floatRateIndex.ResetTenor, floatRateIndex.DayCountBasis) { Nominal = Convert.ToDecimal(notional), Currency = floatRateIndex.Currency, Direction = SwapPayReceiveType.Pay, NotionalExchange = ExchangeType.Both, LegType = SwapLegType.Float, FixedRateOrMargin = Convert.ToDecimal(spread) }; Spread = spread; var schedule = leg.GenerateSchedule(); FloatRateIndex = floatRateIndex; ForecastCurve = forecastCurve; DiscountCurve = discountCurve; LoanDepoSchedule = schedule; Notional = notional; }