当前位置: 首页>>代码示例>>C#>>正文


C# CarbonClient.GetCalendarAsync方法代码示例

本文整理汇总了C#中CarbonClient.GetCalendarAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CarbonClient.GetCalendarAsync方法的具体用法?C# CarbonClient.GetCalendarAsync怎么用?C# CarbonClient.GetCalendarAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CarbonClient的用法示例。


在下文中一共展示了CarbonClient.GetCalendarAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCalendar

 public static DateTime[] GetCalendar(string otCode_, CarbonClient client_, ThrowBehavior behavior_=ThrowBehavior.DontThrow)
 {
   try
   {
     return client_.GetCalendarAsync(otCode_).Result.Dates.Select(x => x.ToDateTime()).ToArray();
   }
   catch (Exception ex_)
   {
     Exceptions.Rethrow(string.Format("Error getting calendar {0}", otCode_), behavior_, ex_);
   }
   return null;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:12,代码来源:CalendarRetriever.cs

示例2: Get

    public static async Task<IEnumerable<DateTime>> Get(string holidayCode_, CarbonClient cc_)
    {
      IEnumerable<DateTime> ret;
      if (_cache.TryGetValue(holidayCode_, out ret))
        return ret;

      var result = await cc_.GetCalendarAsync(holidayCode_);

      _cache[holidayCode_] = result.Dates.Select(x => x.ToDateTime()).ToList();

      return _cache[holidayCode_];
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:12,代码来源:Holidays.cs

示例3: GetCalendar

 public static DateTime[] GetCalendar(string otCode_, CarbonClient client)
 {
     try
     {
         return client.GetCalendarAsync(otCode_).Result.Dates.Select(x => x.ToDateTime()).ToArray();
     }
     catch (Exception ex_)
     {
         throw new Exception(string.Format("Error getting calendar {0}", ex_));
     }
     return null;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:12,代码来源:Calendar.cs

示例4: getEUTA_Dates

 private static IList<DateTime> getEUTA_Dates(CarbonClient client_)
 {
   var v = client_.GetCalendarAsync("EUTA").Result;
   var list = v.Dates.Select(x => x.ToDateTime().Date).ToList();
   list.Add(new DateTime(2014, 12, 24));
   return list;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:7,代码来源:DataBuilder.cs

示例5: SpreadSeriesToArrayTests

         //---------------------------------------------------------------------------------------------------------
         //[Test]
         public void SpreadSeriesToArrayTests()
        //---------------------------------------------------------------------------------------------------------
         {
             // Params.
             DateTime start = new DateTime(2016, 2, 28);
             DateTime end = new DateTime(2016, 3, 18);
             List<String> tickers = new List<string>() { "TUH6", "TUM6", "TUU6" };
             string samplingFreq = "1b";

             // Default Configs
             SpreadTimeSeriesConfigs config = new SpreadTimeSeriesConfigs("US");
             string forecastCurveName = config.forecastCurveName;
             string discountCurveName = config.discountCurveName;
             string ccy = config.ccy;
             string calendarcode = config.calendarcode;
             string futuresStaticMoniker = config.futuresStaticMoniker;
             string carbonEnv = config.carbonEnv;
             BondAnalytics.Country country = config.country;
             BondAnalytics.DayCountType dct = config.dct;
             long swpfixfreq = config.swpfixfreq;
             long swpfloatfreq = config.swpfloatfreq;
             long bndCouponFreq = config.bndCouponFreq;
             int BlendIndex = config.BlendIndex;
             bool bForecastCurve = true;

             // Bond Static
             Dictionary<string, TimeSeriesBondStatic> bondstatic = new Dictionary<string, TimeSeriesBondStatic>()
             {
                 {"US912828G799", new TimeSeriesBondStatic("US912828G799", new DateTime(2017,12,15), new DateTime(2015,12,15),DateTime.MinValue,1.0)},
                 {"US912828J686", new TimeSeriesBondStatic("US912828J686", new DateTime(2018,03,15), new DateTime(2015,03,16),DateTime.MinValue,1.0)},
                 {"US912828VK31", new TimeSeriesBondStatic("US912828VK31", new DateTime(2018,06,30), new DateTime(2015,07,01),DateTime.MinValue,1.0)}
             };


             //Spread Static
             SpreadConventions spreadconventions = new SpreadConventions(country, dct, swpfixfreq, swpfloatfreq, bndCouponFreq, bForecastCurve, BlendIndex);


             // Dates
             var holidays = new List<DateTime>();
             var dateRange = new List<DateTime>();

             using (var client = new CarbonClient(carbonEnv))
             {

                 // Holidays
                 if (calendarcode != "")
                 {
                     var nodaHols = client.GetCalendarAsync(calendarcode).Result.Dates;

                     foreach (LocalDate hol in nodaHols)
                     {
                         holidays.Add(hol.ToDateTime());
                     }
                 }

                 // DateRange
                 DateTime startDate = start.AddTenor(Tenor.FromString("1b"), "").AddTenor(Tenor.FromString("-1b"), "");
                 DateTime nextDate = end.AddTenor(Tenor.FromString("1b"), "").AddTenor(Tenor.FromString("-1b"), "");
                 //TimeSpan EOD = new TimeSpan(23, 59, 59);
                 /*if (startDate > nextDate)
                 {
                     return "Error! Bad Inputs!";
                 }*/
                 var tenor = Tenor.FromString("-" + samplingFreq);
                 while (nextDate >= startDate)
                 {
                     dateRange.Add(nextDate);
                     nextDate = BondAnalytics.PrevBusDay(nextDate.AddTenor(tenor, ""), holidays);
                 }

             }

             //Swap.
             var swapBuilder = new SwapCurveSeriesBuilder(dateRange, forecastCurveName, discountCurveName, ccy, holidays, mCarbonClient);
             swapBuilder.buildAllCurves();

             // Futures.
             var seriesBuilder = new FuturesSeriesBuilder(tickers, dateRange, holidays, futuresStaticMoniker, mCarbonClient, carbonEnv);

             // Spread Series.
             Dictionary<string, double> testVals = new Dictionary<string, double>()
             {
                 {"Price", 109.1015625},
                 {"Yield", 0.009007303 * 10000},
                 {"TrueSpread",6.7788999},
                 {"MMS", 0.009689381* 10000},
                 {"Spread", 6.820787365}
             };


             Dictionary<string /*metric*/, SpreadSeriesBuilder /*builder*/> spreadbuildermap = new Dictionary<string, SpreadSeriesBuilder>();

             SpreadSeriesBuilder output = null;
             foreach (var metric in testVals.Keys.ToList())
             {
                 output = new SpreadSeriesBuilder(metric, seriesBuilder, swapBuilder, bondstatic, spreadconventions);
                 Console.WriteLine(metric + " :");
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:TimeSeriesAnalyticsTests.cs


注:本文中的CarbonClient.GetCalendarAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。