public static void TestArcticDateTimeIndex(string lib = "net.securities", string host = "localhost", bool purge = true, bool del = true, string symbol = "S1") { var driver = new MongoClient("mongodb://" + host); var arctic = new Arctic(driver, lib, purge: purge); if (del) { var delcnt = arctic.DeleteAsync(symbol).Result; Console.WriteLine("Deleted {0} versi\tons for {1}".Args(delcnt, symbol)); } var df = new DataFrame(new Series[] { new DateTimeSeries(new[] { new DateTime(2014, 1, 1), new DateTime(2014, 2, 1) }, name: "date"), new Series <long>(new long[] { 1, 2 }, name: "val") }, index: "date"); var df2 = new DataFrame(new Series[] { new DateTimeSeries(new[] { new DateTime(2014, 3, 1), new DateTime(2014, 4, 1) }, name: "date"), new Series <long>(new long[] { 3, 4 }, name: "val") }, index: "date"); var df4 = new DataFrame(new Series[] { new DateTimeSeries(new[] { new DateTime(2014, 3, 1), new DateTime(2014, 4, 1), new DateTime(2014, 5, 1) }, name: "date"), new Series <long>(new long[] { 3, 4, 5 }, name: "val") }, index: "date"); var df3 = new DataFrame(new Series[] { new DateTimeSeries(new[] { new DateTime(2014, 5, 1), new DateTime(2014, 6, 1) }, name: "date"), new Series <long>(new long[] { 5, 6 }, name: "val") }, index: "date"); Stopwatch sw = new Stopwatch(); sw.Start(); var version = arctic.AppendAsync(symbol, df, CHUNKSIZE).Result; var version2 = arctic.AppendAsync(symbol, df2, CHUNKSIZE).Result; var version3 = arctic.AppendAsync(symbol, df2, CHUNKSIZE).Result; var version4 = arctic.AppendAsync(symbol, df4, CHUNKSIZE).Result; var read1 = arctic.Read(symbol, new DateRange(new DateTime(2014, 3, 1))); Console.WriteLine(read1); var read2 = arctic.Read(symbol, new DateRange(new DateTime(2014, 1, 1), new DateTime(2014, 2, 1))); Console.WriteLine(read2); sw.Stop(); long rows = df.Rows.Count;// + df2.Rows.Count; Console.WriteLine("write {0} took {1}s = {2}/sec -> ver:\n {3}".Args(rows, sw.Elapsed.TotalSeconds, rows / sw.Elapsed.TotalSeconds, version)); }
public static void TestMetadata(string lib = "net.securities", string host = "localhost", bool purge = true, bool del = true, string symbol = "S1") { var driver = new MongoClient("mongodb://" + host); var arctic = new Arctic(driver, lib, purge: purge); if (del) { var delcnt = arctic.DeleteAsync(symbol).Result; Console.WriteLine("Deleted {0} versi\tons for {1}".Args(delcnt, symbol)); } var df = new DataFrame(); df.FilledCount = 2; df.Col <DateTime>("date")[0] = new DateTime(2015, 1, 1); df.Col <DateTime>("date")[1] = new DateTime(2015, 2, 1); df.Col <long>("value")[0] = 15; df.Metadata["sector"] = "internet"; df.Index = df["date"]; arctic.Append("AAPL", df); var df1 = arctic.Read("AAPL"); Console.WriteLine($"AAPL metadata {df1.Metadata["sector"]}"); }