private static UnderlyingAsset CreateSimpleFra(string marketInstrumentId) { var simpleFra = new SimpleFra(); string[] slicedInstrumentId = marketInstrumentId.Split('-'); string instrumentCurrency = slicedInstrumentId[0]; string instrumentTerm = slicedInstrumentId[2]; simpleFra.currency = new IdentifiedCurrency { Value = instrumentCurrency }; string startTerm; string endTerm = slicedInstrumentId[3]; if (endTerm != null) { startTerm = instrumentTerm; Period temp = PeriodHelper.Parse(endTerm); simpleFra.startTerm = PeriodHelper.Parse(startTerm); simpleFra.endTerm = simpleFra.startTerm.Sum(temp); } else { string[] slicedTerm = instrumentTerm.Split("vxVX".ToCharArray());//TODO fix this for index tenors. startTerm = slicedTerm[0]; endTerm = slicedTerm[1]; simpleFra.startTerm = PeriodHelper.Parse(startTerm); simpleFra.endTerm = PeriodHelper.Parse(endTerm); } simpleFra.instrumentId = new[] { new InstrumentId() }; simpleFra.instrumentId[0].Value = marketInstrumentId; return(simpleFra); }
public static RelativeDateOffset Create(string s, DayTypeEnum dayType, string businessDayConventionAsString, BusinessCenters businessCenters, string dateRelativeTo) { var result = new RelativeDateOffset(); Period interval = PeriodHelper.Parse(s); result.period = interval.period; result.periodMultiplier = interval.periodMultiplier; result.dayType = dayType; result.dayTypeSpecified = true; result.businessDayConvention = BusinessDayConventionHelper.Parse(businessDayConventionAsString); result.businessCenters = businessCenters; var dateReference = new DateReference { href = dateRelativeTo }; result.dateRelativeTo = dateReference; return(result); }
public static FloatingRateCalculation Create(string floatingRateIndex, string indexTenor, decimal spreadInitialValue) { FloatingRateCalculation result = new FloatingRateCalculation(); result.floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex); result.indexTenor = PeriodHelper.Parse(indexTenor); result.spreadSchedule = new SpreadSchedule[] { SpreadScheduleFactory.Create(spreadInitialValue) }; return(result); }
/// <summary> /// Parses the specified interval as string. /// </summary> /// <param name="intervalAsString"><example>3M,3m,14d,6Y</example></param> /// <returns></returns> public static ResetFrequency Parse(string intervalAsString) { ResetFrequency result = new ResetFrequency(); Period interval = PeriodHelper.Parse(intervalAsString); result.periodMultiplier = interval.periodMultiplier; result.period = interval.period.ToString(); return(result); }
public Period ToPeriod() { string[] nameParts = id.Split('-'); if (nameParts.Length < 3) { throw new ArgumentException("UnderlyingAsset Id must have at least three parts separated by '-'"); } string termPart = nameParts[2]; return(PeriodHelper.Parse(termPart)); }
private static UnderlyingAsset CreateDeposit(string marketInstrumentId) { var deposit = new Deposit(); string[] slicedInstrumentId = marketInstrumentId.Split('-'); string instrumentCurrency = slicedInstrumentId[0]; string instrumentTerm = slicedInstrumentId[2]; deposit.currency = new IdentifiedCurrency { Value = instrumentCurrency }; deposit.term = PeriodHelper.Parse(instrumentTerm); deposit.instrumentId = new[] { new InstrumentId() }; deposit.instrumentId[0].Value = marketInstrumentId; return(deposit); }
private static UnderlyingAsset CreateSimpleIRSwap(string marketInstrumentId) { var simpleIRSwap = new SimpleIRSwap(); string[] slicedInstrumentId = marketInstrumentId.Split('-'); string instrumentCurrency = slicedInstrumentId[0]; string instrumentTerm = slicedInstrumentId[2]; simpleIRSwap.currency = new IdentifiedCurrency { Value = instrumentCurrency }; simpleIRSwap.term = PeriodHelper.Parse(instrumentTerm); simpleIRSwap.instrumentId = new[] { new InstrumentId() }; simpleIRSwap.instrumentId[0].Value = marketInstrumentId; return(simpleIRSwap); }
public static RateIndex Parse(string instrumentId, string floatingRateIndex, string currency, string dayCountFraction, string paymentFrequency, string term) { var rateIndex = new RateIndex { currency = new IdentifiedCurrency() { Value = currency }, dayCountFraction = DayCountFractionHelper.Parse(dayCountFraction), floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex), id = instrumentId, instrumentId = InstrumentIdArrayHelper.Parse(instrumentId), paymentFrequency = PeriodHelper.Parse(paymentFrequency), term = PeriodHelper.Parse(term) }; return(rateIndex); }
public static Period FromYears(int years) { return(PeriodHelper.Parse(years + "Y")); }
public static Period FromMonths(int months) { return(PeriodHelper.Parse(months + "M")); }
public static Period FromWeeks(int weeks) { return(PeriodHelper.Parse(weeks + "W")); }
public static Period FromDays(int days) { return(PeriodHelper.Parse(days + "D")); }