Пример #1
0
      public static async Task Go(ICarbonClient cc_)
      {
        DFsWorker.DFInstance().ToString();

        await DFsCache.Instance().RefreshFromServerIfLocalCacheEmpty();
        await TenorDatesCache.Instance().RefreshFromServerIfLocalCacheEmpty();

        var defs = new ISwapCurveDefinition[]
        {
          new USD3mLibor(),
          new USDFedfunds(),
          new EUR6mEuribor(),
          new EUREonia(),
          new GBP6mLibor(),
          new GBPSonia(),
        };

        var sets = new[]
        {
          Tuple.Create(PreDefinedSet.SpotStartOutrights,new[] { "spot","outrights"}),
          Tuple.Create(PreDefinedSet.SpotStartCurves,new[] { "spot","curves"}),
          Tuple.Create(PreDefinedSet.SpotStartButterflies,new[] { "spot","butterflies"}),
          Tuple.Create(PreDefinedSet.FwdOutrights,new[] { "fwd","outrights"}),
          Tuple.Create(PreDefinedSet.FwdCurves,new[] { "fwd","curves"}),
          Tuple.Create(PreDefinedSet.FwdButterflies,new[] { "fwd","butterflies"}),
        };

        foreach (var curveDef in defs)
        {
          foreach (var set in sets)
          {
            var points = UserListHelper.GetStructuresForSet(set.Item1);
            var dataframeMoniker = string.Format("symapp.rates.{0}.{1}.{2}", curveDef.CurveName, set.Item2[0],
              set.Item2[1]);

            var con = new ConstructGen<double>(points.Length);
            con.ColumnHeadings = new string[points.Length];

            for (int i = 0; i < points.Length; ++i)
            {
              InstrumentWithStatsSwap sw = null;
              var point = points[i];
              switch (point.Length)
              {
                case 1:
                  sw = OutrightSwap.Get(curveDef.CurveName, point[0]); break;
                case 2:
                  sw = CurveSwap.Get(curveDef.CurveName, AB_: point[0], CD_: point[1]); break;
                case 3:
                  sw = ButterflySwap.Get(curveDef.CurveName, w1_: point[0], belly_: point[1], w2_: point[2]); break;
              }

              if (sw != null)
              {
                con.ColumnHeadings[i] = sw.Description;
                con.SetColumnValues(i, sw.A_Prices);
              }
            }

            var deedle = con.ToDeedle();

            Logger.Info(string.Format("Writing {0} to carbon dataframes", dataframeMoniker),
              typeof (PersistSetsForDeriveddataWorker));
            await cc_.SaveFrameAsync(dataframeMoniker, deedle);
          }
        }

      }