public async void PrependData() { XmlDataBase tb = new XmlDataBase(); List <Bar> barList = new List <Bar>(); var firstDt = new DateTime(2019, 1, 1, 5, 0, 0); barList.Add(new Bar(10, 20, 5, 12, 0, firstDt)); barList.Add(new Bar(15, 25, 10, 17, 0, firstDt.AddMinutes(5))); barList.Add(new Bar(15, 27, 8, 17, 0, firstDt.AddMinutes(10))); var instrument = new Instrument { Type = InstrumentType.Stock, Name = "GLD" }; var resolution = new Resolution(TimeFrame.Hourly, 1); var b = await tb.WriteLocalDataAsync(instrument, resolution, barList); barList.Clear(); barList.Add(new Bar(1, 20, 5, 12, 0, firstDt.AddMinutes(-60))); barList.Add(new Bar(0, 25, 10, 17, 0, firstDt.AddMinutes(-55))); barList.Add(new Bar(0, 27, 8, 17, 0, firstDt.AddMinutes(-50))); _ = tb.PrependLocalData(instrument, resolution, barList); var rbs = await tb.ReadLocalDataAsync(instrument, resolution, firstDt.AddMinutes(-60), firstDt.AddMinutes(15)); Assert.AreEqual(6, rbs.Count()); }
public void PrependData() { XmlDataBase tb = new XmlDataBase(); List <Bar> barList = new List <Bar>(); barList.Add(new Bar(10, 20, 5, 12, 0, DateTime.Now, DateTime.Now)); barList.Add(new Bar(15, 25, 10, 17, 0, DateTime.Now, DateTime.Now)); barList.Add(new Bar(15, 27, 8, 17, 0, DateTime.Now, DateTime.Now)); var instrument = new Instrument { Type = InstrumentType.Stock, Name = "GLD" }; var resolution = new Resolution(TimeFrame.Hourly, 1); tb.WriteLocalData(instrument, resolution, barList); barList.Clear(); barList.Add(new Bar(1, 20, 5, 12, 0, DateTime.Now, DateTime.Now)); barList.Add(new Bar(0, 25, 10, 17, 0, DateTime.Now, DateTime.Now)); barList.Add(new Bar(0, 27, 8, 17, 0, DateTime.Now, DateTime.Now)); tb.PrependLocalData(instrument, resolution, barList); var rbs = tb.ReadLocalData(instrument, resolution, DateTime.Now, DateTime.Now); Assert.AreEqual(6, rbs.Count()); }