Esempio n. 1
0
    private static async Task populateKnown(CarbonClient cc_)
    {
      var knownMonikers = AssetClassMonikerRoots.Roots.Select(x => string.Format("{0}.secmaster", x));

      m_list = new ConstructGenGen<string, SecMasterEntry>(new[] {"Value"});

      foreach (var moniker in knownMonikers)
      {
        Logger.Info(string.Format("Loading secmaster document [{0}]...", moniker), typeof (SecMasters));

        var s = await DataFrameHelper.GetDataFrameByColumn(
          name_: moniker,
          keyExtractor_: x => x.ToString(),
          valueExtractor_: (idx,col) =>
          {
            var invertValue = col[idx["invert"]];

            bool invert;

            if (invertValue is bool)
              invert = (bool) col[idx["invert"]];
            else
              bool.TryParse(invertValue.ToString(), out invert);

            var method = (string) col[idx["method"]];

            PnlMethod mthd = PnlMethod.Arithmetic;

            switch(method.ToLower())
            {
              case "arithmetic":
                mthd = PnlMethod.Arithmetic;break;
              case "geometric":
                mthd = PnlMethod.Geometric;break;
              case "swaps":
                mthd = PnlMethod.Swap;break;
              case "credit":
                mthd = PnlMethod.Credit;break;
              default:
                Logger.Warn(string.Format("Unknown pricing method of '{0}'. Will default to arithmetic.", method),
                  typeof (SecMasters));
                break;
            }

            return new SecMasterEntry
            {
              Invert = invert,
              Method = mthd
            };
          },
          cc_: cc_);

        if(s!=null)
          foreach (var key in s.Keys)
          {
            var val = s.GetValue(key, 0);
            val.Name = key;

            if (m_list.HasKey(key))
            {
              var currentValue = m_list.GetValue(key, 0);

              if (!currentValue.Equals(val))
              {
                Logger.Error(
                  string.Format(
                    "Entry for {0} is being overwritten with different values from another list.  PriorSettings={1}.  NewSettings={2}",
                    val.Name, currentValue, val), typeof (SecMasters));
              }
            }

            m_list.SetValue(key, 0, val);
          }

      }
    }