public IrSwap(FloatLeg floatLeg, FixedLeg fixedLeg, int tradeSign) { FloatLeg = floatLeg; FixedLeg = fixedLeg; if (tradeSign == 1 || tradeSign == -1) { TradeSign = tradeSign; } else { throw new InvalidOperationException("TradeSign has to be 1 (pay fixed) or -1 (pay float)"); } }
public TenorBasisSwap(FloatLeg floatLegSpread, FloatLeg floatLegNoSpread, int tradeSign) { this.FloatLegNoSpread = floatLegNoSpread.Copy(); this.FloatLegSpread = floatLegSpread.Copy(); // Construct default FixedLeg - quick and dirty FixedLeg tempFixedLeg = new FixedLeg(floatLegNoSpread.AsOf, floatLegSpread.StartDate, floatLegSpread.EndDate, 0.01, CurveTenor.Fwd1Y, DayCount.THIRTY360, DayRule.MF, floatLegSpread.Notional); SwapSpread = new IrSwap(floatLegSpread, tempFixedLeg, tradeSign); SwapNoSpread = new IrSwap(floatLegNoSpread, tempFixedLeg, -1 * tradeSign); TradeSign = tradeSign; CheckTradeSign(); ConstructedFromFloatingLegs = true; }
public IrSwap(DateTime asOf, DateTime startDate, DateTime endDate, double fixedRate, CurveTenor fixedFreq, CurveTenor floatFreq, DayCount fixedDayCount, DayCount floatDayCount, DayRule fixedDayRule, DayRule floatDayRule, double notional, int tradeSign, double spread = 0.0) { FloatLeg = new FloatLeg(asOf, startDate, endDate, floatFreq, floatDayCount, floatDayRule, notional, spread); FixedLeg = new FixedLeg(asOf, startDate, endDate, fixedRate, fixedFreq, fixedDayCount, fixedDayRule, notional); if (tradeSign == 1 || tradeSign == -1) { TradeSign = tradeSign; } else { throw new InvalidOperationException("TradeSign has to be 1 (pay fixed) or -1 (pay float)"); } }
public ADouble ValueFloatLegNoSpreadAD(FloatLeg floatLeg) { ADouble floatValue = 0.0; ADouble spread = 0.0; for (int i = 0; i < floatLeg.Schedule.AdjStartDates.Count; i++) { DateTime startDate = floatLeg.Schedule.AdjStartDates[i]; DateTime endDate = floatLeg.Schedule.AdjEndDates[i]; ADouble cvg = floatLeg.Schedule.Coverages[i]; ADouble fwdRate = ADFwdCurveCollection.GetCurve(floatLeg.Tenor).FwdRate(floatLeg.AsOf, startDate, endDate, floatLeg.Schedule.DayRule, floatLeg.Schedule.DayCount, Interpolation); ADouble discFactor = ADDiscCurve.DiscFactor(floatLeg.AsOf, endDate, floatLeg.DayCount, Interpolation); floatValue = floatValue + (fwdRate + spread) * cvg * discFactor; } return(floatValue * floatLeg.Notional); }