Example #1
0
 public void ItemsT_property_has_count_4()
 {
     using (TeaFile <OHLCV> f = TeaFile <OHLCV> .Create(Guid.NewGuid() + "lab1.tea"))
     {
         4.Times(() => f.Write(new OHLCV {
             Open = 111
         }));
         var items = f.Items;
         Assert.AreEqual(4, items.Count);
     }
 }
Example #2
0
 static void WriteDailyTicks(TeaFile<Tick> tf, Time day, bool isGoodDay)
 {
     Time t = day.AddHours(9); // start trading session at 09:00
     Time end = day.AddHours(17.5); // end trading session at 17:30
     while (t < end)
     {
         //  on a good day, we write many ticks, on a bad day however only 1 percent as much
         if (isGoodDay || DrawRandom(1))
         {
             double p = r.NextDouble() * 100000.0;
             tf.Write(new Tick {Time = t, Price = p, Volume = 10});
         }
         t = t.AddSeconds(15 + r.Next(0, 20));
     }
 }
Example #3
0
        public void ItemsT_CountProperty_reflects_actual_number_of_items()
        {
            string filename = Guid.NewGuid() + "lab1.tea";

            using (TeaFile <OHLCV> f = TeaFile <OHLCV> .Create(filename))
            {
                Assert.AreEqual(0, f.Items.Count);
                f.Write(new OHLCV {
                    Open = 111
                });
                Assert.AreEqual(1, f.Items.Count, "After writing an item, Count is 1");
            }

            using (var f = TeaFile <OHLCV> .OpenRead(filename))
            {
                Assert.AreEqual(1, f.Items.Count);
            }
        }