/// <summary> /// Add a column to the collection of columns to be returned /// </summary> /// <param name="datasource">The datasource</param> /// <param name="column">The column to add</param> public void AddColumn(Datacode datasource, int column) { if (_datacolumns.Length > 0) { _datacolumns.Append(','); } _datacolumns.Append(string.Format("{0}.{1}", datasource.ToDatacodeString('.'), column)); }
public void GetDatacode_Correct() { var datacode = new Datacode() { Source = "PRAGUESE", Code = "PX" }; Assert.AreEqual("PRAGUESE/PX", datacode.ToDatacodeString('/'), "The unique code should be the Source and Code separated by a forward slash"); }
public static RootObject GetRandomData(Datacode dc, int numrecords, decimal basevalue, decimal mult, DateTime startdate) { RootObject ro = new RootObject(); if (dc!=null) ro.source_code = dc.ToDatacodeString('.'); System.Random rnd = new Random(); ro.id = rnd.Next(1, 1000000); ro.isCacheable = false; ro.column_names = new List<string>(); ro.column_names.Add(qh.DefaultDateColumnName); ro.column_names.Add(qh.DefaultValueColumnName); ro.data = new List<List<object>>(); for (int i = 0; i < numrecords; i++) { var val = ((decimal)rnd.NextDouble() * mult) + basevalue; var date = new DateTime(startdate.Ticks); ro.data.Add(new List<object>(new object[] { date,val })); // next date startdate = startdate.AddDays(1); } return ro; }
/// <summary> /// Add all columns for the supplied datasource /// </summary> /// <param name="datasource">The datasource</param> public void AddColumns(Datacode datasource) { if (_datacolumns.Length > 0) { _datacolumns.Append(','); } _datacolumns.Append(datasource.ToDatacodeString('.')); }
/// <summary> /// gets pretty quandl code /// </summary> /// <param name="dc"></param> /// <returns></returns> public static string DataCode2String(Datacode dc) { return dc.ToDatacodeString('.'); }