/// <summary> /// Deal settle. /// </summary> /// <param name="dealDate"></param> /// <param name="settC"></param> /// <param name="hols"></param> /// <returns></returns> public static DateTime SettFromDeal(DateTime dealDate, BondSettlementEnum settC, IBusinessCalendar hols) { switch (settC) { case BondSettlementEnum.SC_dealDate: return(dealDate); case BondSettlementEnum.SC_1bd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(1), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_2bd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(2), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_1b1cd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(1), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING).AddDays(1)); case BondSettlementEnum.SC_3bd: case BondSettlementEnum.SC_3bd_6bdLO: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(3), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_3b1cd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(3), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING).AddDays(1)); case BondSettlementEnum.SC_4bd: case BondSettlementEnum.SC_4bd_6bdLO: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(4), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_5bd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(5), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_7bd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(7), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_3d: return(hols.Roll(dealDate.AddDays(3), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_7d: return(hols.Roll(dealDate.AddDays(7), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_7c1bd: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(7), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); case BondSettlementEnum.SC_3cd: return(hols.Roll(dealDate.AddDays(3), BusinessDayConventionEnum.FOLLOWING)); // case BondSettlementHelper.BondSettlementEnum.SC_Canada: // return default: return(hols.Advance(dealDate, OffsetHelper.FromInterval(IntervalHelper.FromDays(1), DayTypeEnum.Business), BusinessDayConventionEnum.FOLLOWING)); } /* switch (settC) * { * case SC_Canada: * CalendarDate(ym, mm, dm, maturityDate); * return TCs->NextBizDay(dealDate, 2 + (dealDate <= UnadjustedDate(ym - 3, mm, dm))); * * case SC_Austria: return TCs->NextBizDay(dealDate + 15 - DayOfWeek(dealDate), 0); * * case SC_Australia: * CalendarDate(ym, mm, dm, maturityDate); * return TCs->NextBizDay(dealDate, dealDate > UnadjustedDate(ym, mm - 6, dm) ? 1 : 3); * * case SC_SouthAfrica: * settDate = dealDate + 15 - DayOfWeek(dealDate + 4); * if (!TCs->IsBizDay(settDate + 1)) settDate--; * return settDate; * } * return dealDate;*/ }
/// <summary> /// Formats the type. /// </summary> /// <param name="SettC"></param> /// <returns></returns> public static string FormatBondSettlement(BondSettlementEnum SettC) { switch (SettC) { case BondSettlementEnum.SC_dealDate: return("Deal"); case BondSettlementEnum.SC_1bd: return("1bd"); case BondSettlementEnum.SC_2bd: return("2bd"); case BondSettlementEnum.SC_1b1cd: return("1bd1cd"); case BondSettlementEnum.SC_3bd: return("3bd"); case BondSettlementEnum.SC_3b1cd: return("3bd1cd"); case BondSettlementEnum.SC_4bd: return("4bd"); case BondSettlementEnum.SC_5bd: return("5bd"); case BondSettlementEnum.SC_7bd: return("7bd"); case BondSettlementEnum.SC_3d: return("3cd"); case BondSettlementEnum.SC_3cd: return("3cd"); case BondSettlementEnum.SC_7d: return("7cd"); case BondSettlementEnum.SC_7c1bd: return("7cd1bd"); // case BondSettlementHelper.BondSettlementEnum.SC_Canada: return "Canadian"; // case BondSettlementHelper.BondSettlementEnum.SC_Austria: return "Austrian"; // case BondSettlementHelper.BondSettlementEnum.SC_Australia: return "Australian"; // case BondSettlementHelper.BondSettlementEnum.SC_SouthAfrica: return "South African"; case BondSettlementEnum.SC_3bd_6bdLO: return("3bd (6bd LO)"); case BondSettlementEnum.SC_4bd_6bdLO: return("4bd (6bd LO)"); default: return(""); } }
/// <summary> /// PriceableBond /// </summary> /// <param name="name"></param> /// <param name="instrumentid"></param> /// <param name="bondType"></param> /// <param name="dealDate"></param> /// <param name="valueDate"></param> /// <param name="ccy"></param> /// <param name="calendar"></param> /// <param name="coupFreq"></param> /// <param name="accrualDC"></param> /// <param name="yieldDC"></param> /// <param name="repoDC"></param> /// <param name="xdt"></param> /// <param name="couponType"></param> /// <param name="couponRate"></param> /// <param name="settC"></param> /// <param name="maturity"></param> /// <param name="valueC"></param> /// <param name="tickSize"></param> /// <param name="issuerName"></param> /// <param name="ycm"></param> /// <param name="yieldCompFreq"></param> /// <param name="accIntRounding"></param> public PriceableBond(string name, string instrumentid, string bondType, DateTime dealDate, DateTime valueDate, Currency ccy, IBusinessCalendar calendar, Period coupFreq, DayCountFraction accrualDC, DayCountFraction yieldDC, DayCountFraction repoDC, ExDividendEnum xdt, CouponTypeEnum couponType, decimal couponRate, string settC, DateTime maturity, BondSettlementEnum valueC, short tickSize, string issuerName, BondAnalytics.YieldCalcMethod ycm, short yieldCompFreq, short accIntRounding) : base(dealDate, 100.0m, ccy, null, null, null, null) { Currency = ccy; ValueDate = valueDate; DealDate = dealDate; Frequency = int.Parse(coupFreq.periodMultiplier); //convert to using the bond fpml paymentfrequency field. AccIntRounding = accIntRounding; CouponType = couponType; CouponRate = couponRate; CouponDayCount = accrualDC; BondType = EnumHelper.Parse <BondTypesEnum>(bondType); PaymentDateCalendar = calendar; RepoDC = repoDC; SettC = settC; TickSize = tickSize; ValueC = valueC; Xdt = xdt; Ycm = ycm; YieldCompFreq = yieldCompFreq; YieldDC = yieldDC; RollDay = maturity.Day; //provide an input for this. ValueDate = SettlementDate; //default condition if not specified. Id = name; Issuer = issuerName; //Does not handle PartyReference type -> only string! MaturityDate = maturity; CouponFrequency = coupFreq; CouponType = CouponTypeEnum.Fixed; InstrumentIds = new List <InstrumentId> { InstrumentIdHelper.Parse(instrumentid) }; Build(); }