public async Task UpdateList(IList<SeriesConfig> list_, ICarbonClient client_)
    {
      // remove current items
      var currentItems = list_.Where(x => x.Source != null && x.Source.ToLower().Equals(SourceName)).ToArray();
      foreach (var item in currentItems)
        list_.Remove(item);

      // search for frames that match the regex

      Logger.Info(string.Format("Searching for dataframes with regex=[{0}]", MonikerSearchRegex),
        typeof (DataframeSearcherBase));

      var monikers = await client_.GetSavedIdentifiersAsync("AdHocData", MonikerSearchRegex, true);

      foreach (var moniker in monikers)
      {
        Logger.Info(string.Format("Considering [{0}]...", moniker), typeof (DataframeSearcherBase));

        try
        {
          var frame = await client_.GetFrameAsync<DateTime>(moniker);

          foreach (var columnName_ in frame.ColumnKeys)
          {
            try
            {
              // attempt to try and get a timeseries
              var series = frame.ExtractTimeSeries<double>(columnName_);

              if (series == null) continue;

              var config = getConfigLine(moniker, columnName_);

              if (config == null) continue;

              list_.Add(config);
            }
            catch
            {
              //Logger.Info(string.Format("Not going to add column [{0}] as can't get doubles from it", columnName_),
              //  typeof (DataframeSearcherBase));
            }
          }
        }
        catch (Exception ex_)
        {
          Logger.Error(string.Format("Error getting and reflecting on frame {0}", moniker),
            typeof (DataframeSearcherBase), ex_);
        }
      }
    }
Пример #2
0
            getCTDMoniker(string country, string futureticker, ICarbonClient client)
        // ----------------------------------------------------------------------------------------
        {
            string defaultmoniker = "symapp.roll.ctd";
            country = country.ToLower();

            // Column mappings
            var col_prefixes = new Dictionary<string, string>() {{"front", ""}, {"back", "o"}};

            // Get right cols and monikers
            var parts       = futureticker.Split('.');

            if (parts.Length !=2) 
                throw new ArgumentException("#Error: Invalid futures name " + futureticker);

            string month    = parts[1].ToLower();
            string ticker   = parts[0].ToLower();

            if (!col_prefixes.ContainsKey(month)) 
                throw new ArgumentException("#Error: Invalid futures name " + futureticker);

            string prefix   = col_prefixes[month];

            var tickercol = prefix + "ticker";
            var pricecol    = prefix + "price";

            var moniker = defaultmoniker + "." + country + "." + ticker;

            // Check to see if it's valid
            var list = client.GetSavedIdentifiersAsync("AdHocData",defaultmoniker + @".*").Result;

            var checks = new HashSet<string>(list);

            if (!checks.Contains(moniker))
            {
                throw new ArgumentException("#Error: Invalid moniker entered " + moniker);
            }

            return new Tuple<string, string, string>(moniker, tickercol,pricecol);
        }
Пример #3
0
            getCTMoniker(string country, string benchmark, ICarbonClient client)
        // ----------------------------------------------------------------------------------------
        {
            string defaultmoniker = "symapp.roll.ct";
            country = country.ToLower();

            var moniker = defaultmoniker + "." + country + "." + benchmark.ToLower();
            var tickercol = "ticker"; // always OTR
            var pricecol  = "price";

            // Check to see if it's valid
            var list = client.GetSavedIdentifiersAsync("AdHocData",defaultmoniker + @".*").Result;

            var checks = new HashSet<string>(list);

            if (!checks.Contains(moniker))
            {
                throw new ArgumentException("#Error: Invalid moniker entered " + moniker);
            }

            return new Tuple<string, string, string>(moniker, tickercol,pricecol);

        }