//------------------------------------------------------------------------------------------------ public SwapCurveSeriesBuilder(DateTime start, DateTime end, string forecastName, string discountName, string ccy, ICarbonClient client, string calendarCode="") //------------------------------------------------------------------------------------------------ { m_startDate = start; m_endDate = end; m_forecastCurveName = forecastName; m_discountCurveName = discountName; m_ccy = ccy; m_carbonClient = client; // Holidays m_holidays = new List<DateTime>(); if (calendarCode != "") { var nodaHols = m_carbonClient.GetCalendarAsync(calendarCode).Result.Dates; foreach (LocalDate hol in nodaHols) { m_holidays.Add(hol.ToDateTime()); } } // Dates m_dateRange = new List<DateTime>(); LocalDate currentDate = m_carbonClient.RollDateAsync(DateUtils.ToLocalDate(m_startDate), 0, DateUnit.Bd, BusinessDayConvention.Following, calendarCode).Result; LocalDate endDate = DateUtils.ToLocalDate(m_endDate); while (currentDate <= endDate) { m_dateRange.Add(DateUtils.ToDateTime(currentDate)); currentDate = m_carbonClient.RollDateAsync(currentDate, 1, DateUnit.Bd, BusinessDayConvention.Following, calendarCode).Result; } buildAllCurves(); }
//------------------------------------------------------------------------------------------------ public FuturesSeriesBuilder(List<string> tickers, DateTime start, DateTime end, string calendarCode, string futuresStaticMoniker, ICarbonClient client, string carbonEnv = "PRD", RollMethods rollMthd = RollMethods.FirstNoticeDate, InterpolationTypes interpType = InterpolationTypes.None, List<string> contractSortOrder = null , Dictionary<string,DateTime> rollmap = null, SmoothingTypes smoothingType = SmoothingTypes.None) //------------------------------------------------------------------------------------------------ { // defaults startDate_ = start; endDate_ = end; carbonEnv_ = carbonEnv; rollMethod_ = rollMthd; //RollMethods.FirstNoticeDate; smoothingType_ = smoothingType; futuresStaticMoniker_ = futuresStaticMoniker; // Holidays holidays_ = new List<DateTime>(); if (calendarCode != "") { var nodaHols = client.GetCalendarAsync(calendarCode).Result.Dates; foreach (LocalDate hol in nodaHols) { holidays_.Add(hol.ToDateTime()); } } // DateRange dateRange_ = new List<DateTime>(); LocalDate currentDate = client.RollDateAsync(DateUtils.ToLocalDate(startDate_), 0, DateUnit.Bd, BusinessDayConvention.Following, calendarCode).Result; LocalDate endDate = DateUtils.ToLocalDate(endDate_); while (currentDate <= endDate) { dateRange_.Add(DateUtils.ToDateTime(currentDate)); currentDate = client.RollDateAsync(currentDate, 1, DateUnit.Bd, BusinessDayConvention.Following, calendarCode).Result; } initFutureSeriesBuilder(tickers, dateRange_, holidays_, futuresStaticMoniker_, client, carbonEnv, rollMthd, interpType, contractSortOrder); }