public static void Collate(BondMarket market_=BondMarket.US)
    {
      var allTenors = SI.ExtensionMethods.CreateArray(1, 30, x => x + 1);

      var con = new ConstructGen<double>(allTenors.Select(x => string.Format("cmt_{0}", x)).ToArray());

      for (int i = 0; i < allTenors.Length; ++i)
      {
        var cr = Get(market_, allTenors[i]);
        if (cr == null) continue;

        con.SetColumnValues(i, cr.Values.GetColumnValuesAsDDC((int) CMTCarry.ColPosition.Carry));
      }

      con.WriteToCSV(string.Format(@"e:\temp\CMTCarry_{0}.csv", market_));
    }
    internal static void Go()
    {
      var listOfTenors = new[]
      {
        "1Y",
        "2Y",
        "3Y",
        "4Y",
        "5Y",
        "6Y",
        "7Y",
        "8Y",
        "9Y",
        "10Y",
        "11Y",
        "12Y",
        "15Y",
        "20Y",
        "25Y",
        "30Y",
        "40Y",
        "1Y1Y",
        "1Y2Y",
        "1Y3Y",
        "1Y4Y",
        "1Y5Y",
        "1Y6Y",
        "1Y7Y",
        "1Y8Y",
        "1Y9Y",
        "1Y10Y",
        "1Y11Y",
        "1Y12Y",
        "1Y15Y",
        "1Y20Y",
        "1Y25Y",
        "1Y30Y",
        "1Y40Y",
        "2Y1Y",
        "2Y2Y",
        "2Y3Y",
        "2Y4Y",
        "2Y5Y",
        "2Y6Y",
        "2Y7Y",
        "2Y8Y",
        "2Y9Y",
        "2Y10Y",
        "2Y11Y",
        "2Y12Y",
        "2Y15Y",
        "2Y20Y",
        "2Y25Y",
        "2Y30Y",
        "2Y40Y",
        "3Y1Y",
        "3Y2Y",
        "3Y3Y",
        "3Y4Y",
        "3Y5Y",
        "3Y6Y",
        "3Y7Y",
        "3Y8Y",
        "3Y9Y",
        "3Y10Y",
        "3Y11Y",
        "3Y12Y",
        "3Y15Y",
        "3Y20Y",
        "3Y25Y",
        "3Y30Y",
        "3Y40Y",
        "4Y1Y",
        "4Y2Y",
        "4Y3Y",
        "4Y4Y",
        "4Y5Y",
        "4Y6Y",
        "4Y7Y",
        "4Y8Y",
        "4Y9Y",
        "4Y10Y",
        "4Y12Y",
        "4Y15Y",
        "4Y20Y",
        "4Y25Y",
        "4Y30Y",
        "4Y40Y",
        "5Y1Y",
        "5Y2Y",
        "5Y3Y",
        "5Y4Y",
        "5Y5Y",
        "5Y6Y",
        "5Y7Y",
        "5Y8Y",
        "5Y9Y",
        "5Y10Y",
        "5Y12Y",
        "5Y15Y",
        "5Y20Y",
        "5Y25Y",
        "5Y30Y",
        "5Y40Y",
        "6Y1Y",
        "6Y2Y",
        "6Y3Y",
        "6Y4Y",
        "6Y5Y",
        "6Y6Y",
        "6Y7Y",
        "6Y8Y",
        "6Y9Y",
        "6Y10Y",
        "6Y12Y",
        "6Y15Y",
        "6Y20Y",
        "6Y25Y",
        "6Y30Y",
        "7Y1Y",
        "7Y2Y",
        "7Y3Y",
        "7Y4Y",
        "7Y5Y",
        "7Y6Y",
        "7Y7Y",
        "7Y8Y",
        "7Y9Y",
        "7Y10Y",
        "7Y11Y",
        "7Y12Y",
        "7Y15Y",
        "7Y20Y",
        "7Y25Y",
        "7Y30Y",
        "8Y1Y",
        "8Y2Y",
        "8Y3Y",
        "8Y4Y",
        "8Y5Y",
        "8Y6Y",
        "8Y7Y",
        "8Y8Y",
        "8Y9Y",
        "8Y10Y",
        "8Y12Y",
        "8Y15Y",
        "8Y20Y",
        "8Y25Y",
        "8Y30Y",
        "9Y1Y",
        "9Y2Y",
        "9Y3Y",
        "9Y4Y",
        "9Y5Y",
        "9Y6Y",
        "9Y7Y",
        "9Y8Y",
        "9Y9Y",
        "9Y10Y",
        "9Y11Y",
        "9Y12Y",
        "9Y15Y",
        "9Y20Y",
        "9Y25Y",
        "9Y30Y",
        "10Y1Y",
        "10Y2Y",
        "10Y3Y",
        "10Y4Y",
        "10Y5Y",
        "10Y10Y",
        "10Y15Y",
        "10Y20Y",
        "10Y30Y",
        "11Y1Y",
        "11Y2Y",
        "11Y3Y",
        "11Y4Y",
        "11Y5Y",
        "11Y6Y",
        "11Y7Y",
        "11Y10Y",
        "11Y15Y",
        "11Y20Y",
        "11Y25Y",
        "11Y30Y",
        "12Y1Y",
        "12Y2Y",
        "12Y3Y",
        "12Y4Y",
        "12Y5Y",
        "12Y8Y",
        "12Y10Y",
        "12Y20Y",
        "12Y25Y",
        "15Y1Y",
        "15Y2Y",
        "15Y3Y",
        "15Y4Y",
        "15Y5Y",
        "15Y6Y",
        "15Y7Y",
        "15Y8Y",
        "15Y9Y",
        "15Y10Y",
        "15Y15Y",
        "20Y5Y",
        "20Y10Y",
        "25Y5Y",
        "30Y10Y",

      };

      ProductList.RegisterMongoClasses();

      foreach (var curve in new[] { CurveNames.USD3M, CurveNames.EUR6M} )
      {
        var con = new ConstructGen<double>(listOfTenors);

        for (int i = 0; i < listOfTenors.Length; ++i)
        {
          var split = listOfTenors[i].Trim('Y').Split('Y');

          int start=0, foward=0;

          if (split.Length == 1)
          {
            foward = int.Parse(split[0]);
          }
          else
          {
            start = int.Parse(split[0]);
            foward = int.Parse(split[1]);
          }

          var series = xYyY.Get(curve, start, foward);

          con.SetColumnValues(i, series.A_Prices);
        }

        if (con.NeedsToSortKeys())
          con.SortKeys();

        con.WriteToCSV(string.Format(@"e:\temp\Mark_Swaps_{0}.csv", curve));
      }
      
    }
    public static void Go()
    {
      var yearOfFile = 2015;

      var ricList = new[] {"ED", "FEI", "FGBL", "FGBM", "FGBS", "TY", "FLG", "FSS", "FGB", "FBTP", "FOAT", "ES", "FDX"};

      var contractMonths = (MonthCode[])Enum.GetValues(typeof(MonthCode));

      var sourceDir = @"E:\futuresData\MarkFiles";
      var markDir = @"e:\futuresData\MarkEllis2";

      var dict = new SortedDictionary<string, DatedDataCollectionGen<double>>();
      var keys = new List<string>();

      foreach (var ricStart in ricList)
      {
        foreach (var contractYear in new[] { 2015, 2016, 2017 })
        {
          foreach (var contractMonth in contractMonths)
          {
            var dates = new List<DateTime>();
            var values = new List<double>();

            foreach (var monthOfFile in new[] { 6, 7, 8 })
            {
              var searchString = string.Format("*{0}-{1}-{2}{3}{4}.csv", yearOfFile, monthOfFile.ToString("00"), ricStart, contractMonth, contractYear - 2010);

              var files = Directory.GetFiles(sourceDir, searchString);

              if (files.Length == 0)
                continue;


              foreach (var item in CsvFile.Read<FuturesIntradaySaver.FuturesLineItem>(files[0]))
              {
                if (item.gmtDate.HasValue && (item.gmtDate.Value.Minute == 32 || item.gmtDate.Value.Minute == 2))
                {
                  item.Date = TimeZoneHelper.ConvertGmtTimeToLondon(item.gmtDate.Value);
                  item.Time = string.Empty;

                  if (item.Date.Hour < 8)
                    continue;

                  if (item.Date.Hour > 17)
                    continue;

                  dates.Add(item.Date);
                  values.Add((item.CloseAsk + item.CloseBid) / 2d);
                }
              }

              //list.ToCsv(string.Join("\\", markDir,
              //  string.Format("{0}-{1}-{2}{3}{4}", yearOfFile, monthOfFile.ToString("00"), UpdateStaticDataForFutures.MAPS[ricStart].Item1, contractMonth, contractYear - 2010)));
            }

            if(dates.Count>0)
            {
              try
              {
                var ticker = string.Format("{0}{1}{2}", UpdateStaticDataForFutures.MAPS[ricStart].Item1, contractMonth, contractYear - 2010);
                keys.Add(ticker);
                dict.Add(ticker, new DatedDataCollectionGen<double>(dates.ToArray(), values.ToArray()));
              }
              catch (Exception ex_)
              {
                Console.WriteLine(ex_.ToString());
              }
            }
          }
        }
      }

      var con = new ConstructGen<double>(keys.ToArray());
      for(int i=0;i<keys.Count;++i)
      {
        con.SetColumnValues(i,dict[keys[i]]);
      }

      if (con.NeedsToSortKeys())
        con.SortKeys();

      con.WriteToCSV(@"e:\futuresData\markDataTo1732.csv");
    }
Exemple #4
0
    public void PublishHourlyVolumes(RollSet set)
    {
      ReadFromCSV();

      var con = new ConstructGen<double>(new[] { MonthFrom, MonthTo, "Spread" });

      var priorVolume = new DatedDataCollectionGen<double>(Lines.Dates,
        Lines.Data.Select(x => x.PriorContractVolume).ToArray())
        .ToGenPeriod(
          periodDateFunction_: x => x,
          areSamePeriodFunction_: functionForSameVolumeBucketing(),
          collationFunction_: x => x.Sum());

      con.SetColumnValues(0, priorVolume);

      var newVolume = new DatedDataCollectionGen<double>(Lines.Dates,
        Lines.Data.Select(x => x.NewContractVolume).ToArray())
        .ToGenPeriod(
          periodDateFunction_: x=>x,
          areSamePeriodFunction_: functionForSameVolumeBucketing(),
          collationFunction_: x => x.Sum());

      con.SetColumnValues(1, newVolume);

      var spreadVolume = new DatedDataCollectionGen<double>(Lines.Dates,
        Lines.Data.Select(x => x.SpreadVolume).ToArray())
        .ToGenPeriod(
          periodDateFunction_: x => x,
          areSamePeriodFunction_: functionForSameVolumeBucketing(),
          collationFunction_: x => x.Sum());

      con.SetColumnValues(2, spreadVolume);

      con.WriteToCSV(string.Format(@"{4}\{0}_{1}_{2}_{3}_HourlyVolume.csv", Rolldate.ToString("yyyyMMdd"), set,
        MonthFrom, MonthTo,DIR));

    }