public override CreditDefaultSwap GenerateInstrument() { var calendar = TradeInfo.Calendar.ToCalendarImpl(); var startDate = TradeInfo.StartDate.ToDate(); var maturityDate = TradeInfo.MaturityDate.ToDate(); var premiumLegNotiaonalFactor = TradeInfo.SwapDirection.ToSwapDirection() == SwapDirection.Payer ? -1 : 1; var premiumLeg = new SwapLeg(startDate, maturityDate, premiumLegNotiaonalFactor * TradeInfo.Notional, false, TradeInfo.Currency.ToCurrencyCode(), new FixedCoupon(TradeInfo.Coupon), calendar, TradeInfo.Frequency.ToFrequency(), TradeInfo.Stub.ToStub(), TradeInfo.DayCount.ToDayCountImpl(), TradeInfo.BusinessDayConvention.ToBda()); var protectionLeg = new CdsProtectionLeg( startDate, maturityDate, null, TradeInfo.Currency.ToCurrencyCode(), -premiumLegNotiaonalFactor * TradeInfo.Notional, TradeInfo.RecoveryRate); return(new CreditDefaultSwap(premiumLeg, protectionLeg, TradeInfo.SwapDirection.ToSwapDirection())); }
protected ICalibrationSupportedInstrument CreateCreditDefaultSwap(RateMktData rateMktData) { var indexType = rateMktData.IndexType.ToIndexType(); var cdsJson = MktInstrumentCdsRule.MktCdsRule[indexType]; var cdsInfo = cdsJson.CreditDefaultSwapInfo; var calendar = cdsInfo.Calendar.ToCalendarImpl(); var startDate = Market.ReferenceDate; var isTernor = rateMktData.IsTerm(); var tenor = isTernor ? rateMktData.Tenor : null; var maturityDate = isTernor ? new Term(tenor).Next(startDate) : new Date(DateTime.Parse(rateMktData.Tenor)); var premiumLeg = new SwapLeg(startDate, maturityDate, 1.0, false, cdsInfo.Currency.ToCurrencyCode(), new FixedCoupon(rateMktData.Rate), calendar, cdsInfo.Frequency.ToFrequency(), cdsInfo.Stub.ToStub(), cdsInfo.DayCount.ToDayCountImpl(), cdsInfo.BusinessDayConvention.ToBda() ); var protectionLeg = new CdsProtectionLeg(startDate, maturityDate, null, cdsInfo.Currency.ToCurrencyCode(), 1.0, cdsInfo.RecoveryRate); return(new CreditDefaultSwap(premiumLeg, protectionLeg, SwapDirection.Payer, tenor, cdsJson.CreditDefaultSwapInfo.NumIntegrationInterval)); }