private FloatingIndex(Currency currency, string name, Tenor tenor) { this.currency = currency; this.name = name; this.tenor = tenor; toString = currency.ToString() + ":" + name.ToUpper() + ":" + tenor.ToString(); }
/// <summary> /// Return a new date with the <paramref name="tenor"/> added to it. /// </summary> /// <param name="tenor">The amount of time to add to the date.</param> /// <returns></returns> public Date AddTenor(Tenor tenor) { DateTime newDate = date.AddYears(tenor.years); newDate = newDate.AddMonths(tenor.months); newDate = newDate.AddDays(tenor.weeks * 7 + tenor.days); return(new Date(newDate)); }
public override bool Equals(object obj) { Tenor t = obj as Tenor; if (t == null) { return(false); } return(this == t); }
/// <summary> /// Creates <paramref name="numberOfDates"/> that are <paramref name="periodTenor"/> apart. The first /// date is <paramref name="startDate"/> plus <paramref name="periodTenor"/>. /// <para/> /// There is no holiday adjustment or stub period. /// </summary> /// <param name="periodTenor">The period tenor.</param> /// <param name="startDate">The start date.</param> /// <param name="numberOfDates">The number of dates.</param> /// <returns></returns> public static void CreateDatesNoHolidays(Tenor periodTenor, Date startDate, int numberOfDates, out Date[] paymentDates, out double[] accrualFractions) { Date runningDate = new Date(startDate); paymentDates = new Date[numberOfDates]; accrualFractions = new double[numberOfDates]; Date oldDate = new Date(startDate); for (int i = 0; i < numberOfDates; i++) { runningDate = runningDate.AddTenor(periodTenor); paymentDates[i] = runningDate; accrualFractions[i] = (runningDate - oldDate) / 365.0; oldDate = runningDate; } }
/// <summary> /// Constructor for ZAR market standard, fixed for float 3m Jibar swap. /// </summary> /// <param name="rate">The fixed rate paid or received</param> /// <param name="payFixed">Is the fixed rate paid?</param> /// <param name="notional">Flat notional for all dates.</param> /// <param name="startDate">First reset date of swap</param> /// <param name="tenor">Tenor of swap, must be a whole number of years.</param> /// <returns></returns> public static IRSwap CreateZARSwap(double rate, bool payFixed, double notional, Date startDate, Tenor tenor) { IRSwap newSwap = new IRSwap(); int quarters = tenor.years * 4 + tenor.months / 3; newSwap.payFixed = payFixed ? -1 : 1; newSwap.indexDates = new Date[quarters]; newSwap.paymentDates = new Date[quarters]; newSwap.index = FloatingIndex.JIBAR3M; newSwap.spreads = new double[quarters];; newSwap.accrualFractions = new double[quarters];; newSwap.notionals = new double[quarters]; newSwap.fixedRate = rate; newSwap.ccy = Currency.ZAR; newSwap.indexValues = new double[quarters]; Date date1 = new Date(startDate); Date date2; for (int i = 0; i < quarters; i++) { date2 = startDate.AddMonths(3 * (i + 1)); newSwap.indexDates[i] = new Date(date1); newSwap.paymentDates[i] = new Date(date2); newSwap.spreads[i] = 0.0; newSwap.accrualFractions[i] = (date2 - date1) / 365.0; newSwap.notionals[i] = notional; date1 = new Date(date2); } return(newSwap); }
/// <summary> /// Creates Bermudan swaption with a simple ZAR swap as underlying, the ZAR swap is the same as that created by: /// <see cref="IRSwap.CreateZARSwap"/>. /// </summary> /// <param name="exerciseDates">The exercise dates. The dates on which the person who is long optionality can exercise.</param> /// <param name="longOptionality">if set to <c>true</c> then the person valuing this product owns the optionality.</param> /// <param name="rate">The fixed rate on the underlying swap.</param> /// <param name="payFixed">if set to <c>true</c> then the underlying swap has the person valuaing the product paying fixed after exercise.</param> /// <param name="notional">The constant notional in ZAR on the underlying swap.</param> /// <param name="startDate">The start date of the underlying swap.</param> /// <param name="tenor">The tenor of the underlying swap.</param> /// <returns></returns> public static BermudanSwaption CreateZARBermudanSwaption(Date[] exerciseDates, bool longOptionality, double rate, bool payFixed, double notional, Date startDate, Tenor tenor) { IRSwap swap = IRSwap.CreateZARSwap(rate, payFixed, notional, startDate, tenor); BermudanSwaption swaption = new BermudanSwaption(swap, exerciseDates.ToList(), longOptionality); return(swaption); }