public SwapLeg Bump(int bp) { if (!(Coupon is FixedCoupon)) { return(this); } else { var newCoupon = new FixedCoupon((Coupon as FixedCoupon).FixedRate + bp * 0.0001); return(new SwapLeg(StartDate, UnderlyingMaturityDate, Notional, NotionalExchange, Currency, newCoupon, Calendar, PaymentFreq, PaymentStub, DayCount, PaymentBda, SettlmentGap, FirstPaymentDate, TerminationDate, TerminationAmount)); } }
public override Bond GenerateInstrument() { ICoupon coupon = null; var calendar = string.IsNullOrEmpty(TradeInfo.Calendar) ? CalendarImpl.Get("chn_ib") : TradeInfo.Calendar.ToCalendarImpl(); if (TradeInfo is FixedRateBondInfo) { var tempTradeInfo = (FixedRateBondInfo)TradeInfo; coupon = new FixedCoupon(tempTradeInfo.FixedCoupon); } else if (TradeInfo is FloatingRateBondInfo) { var tempTradeInfo = (FloatingRateBondInfo)TradeInfo; var index = new Index(tempTradeInfo.Index.ToIndexType(), tempTradeInfo.ResetAverageDays, tempTradeInfo.ResetCompound.ToCouponCompound(), tempTradeInfo.ResetRateDigits); var dayCount = tempTradeInfo.ResetDC.ToDayCountImpl(); var stub = tempTradeInfo.ResetStub.ToStub(); var bda = tempTradeInfo.ResetBD.ToBda(); var floatingCouponResetTerm = new Term(tempTradeInfo.ResetTerm); var resetFrequency = tempTradeInfo.PaymentFreq.ToFrequency(); if (floatingCouponResetTerm.Equals(resetFrequency.GetTerm())) { floatingCouponResetTerm = null; } var resetToFixingGap = new DayGap(tempTradeInfo.ResetToFixingGap); coupon = new FloatingCoupon( index, calendar, dayCount, tempTradeInfo.Spread, floatingCouponResetTerm, stub, bda, resetToFixingGap, null, double.IsNaN(tempTradeInfo.FloorRate) ? -100 : tempTradeInfo.FloorRate, double.IsNaN(tempTradeInfo.CapRate) ? 100 : tempTradeInfo.CapRate, tempTradeInfo.FloatingCalc.ToFloatingCalcType(), (double.IsNaN(tempTradeInfo.FloatingRateMultiplier) || tempTradeInfo.FloatingRateMultiplier.IsAlmostZero()) ? 1.0 : tempTradeInfo.FloatingRateMultiplier ); } else if (TradeInfo is FixedDateCouonAdjustedBondInfo) { var tempTradeInfo = (TradeInfo as FixedDateCouonAdjustedBondInfo); coupon = new FixedDateAdjustedCoupon(tempTradeInfo.Index.ToIndexType(), calendar, tempTradeInfo.DayCount.ToDayCountImpl(), tempTradeInfo.FixedDateCouponAdjustedStyle.ToFixedDateAdjustedCouponStyle(), tempTradeInfo.AdjustMmDd, tempTradeInfo.FloatingRateMultiplier, tempTradeInfo.Spread ); } return(new Bond( TradeInfo.TradeId, TradeInfo.StartDate.ToDate(), TradeInfo.MaturityDate.ToDate(), TradeInfo.Notional, string.IsNullOrEmpty(TradeInfo.Currency) ? CurrencyCode.CNY : TradeInfo.Currency.ToCurrencyCode(), coupon, calendar, TradeInfo.PaymentFreq.ToFrequency(), string.IsNullOrEmpty(TradeInfo.PaymentStub) ? Stub.ShortEnd : TradeInfo.PaymentStub.ToStub(), string.IsNullOrEmpty(TradeInfo.AccrualDC) ? new ActActIsma() : TradeInfo.AccrualDC.ToDayCount().Get(), string.IsNullOrEmpty(TradeInfo.DayCount) ? null : TradeInfo.DayCount.ToDayCount().Get(), TradeInfo.AccrualBD.ToBda(), TradeInfo.PaymentBD.ToBda(), string.IsNullOrEmpty(TradeInfo.Settlement) ? new DayGap("+0D") : new DayGap(TradeInfo.Settlement), string.IsNullOrEmpty(TradeInfo.TradingMarket) ? TradingMarket.ChinaInterBank : TradeInfo.TradingMarket.ToTradingMarket(), TradeInfo.StickToEom, (double.IsNaN(TradeInfo.RedemptionRate) || Math.Abs(TradeInfo.RedemptionRate - 0.0) < double.Epsilon)? null : new Redemption(TradeInfo.RedemptionRate, TradeInfo.RedemptionIncludeLastCoupon ? RedemptionType.SeparatePrincipalWithLastCoupon : RedemptionType.SeparatePrincipal), TradeInfo.FirstPaymentDate.ToDate(), TradeInfo.IsZeroCouponBond, TradeInfo.IssuePrice, (double.IsNaN(TradeInfo.IssueRate) || TradeInfo.IssueRate <= 0.0) ? double.NaN : TradeInfo.IssueRate, string.IsNullOrEmpty(TradeInfo.AmortizationType) ? AmortizationType.None : TradeInfo.AmortizationType.ToAmortizationType(), TradeInfo.AmoritzationInDate == null ? null : TradeInfo.AmoritzationInDate.ToDictionary(x => x.Key.ToDate(), x => x.Value), TradeInfo.AmoritzationInIndex, TradeInfo.RenormAmortization, TradeInfo.CompensationRate, TradeInfo.OptionToCall, TradeInfo.OptionToPut, TradeInfo.OptionToAssPut, TradeInfo.SettlementCoupon.IsAlmostZero() ? double.NaN : TradeInfo.SettlementCoupon, TradeInfo.RoundCleanPrice )); }