Пример #1
0
        public void TimeAlignmentTest()
        {
            IDataManager data   = new Data();
            ISymbol      symbol = new Symbol(data.GetMarket("testMarket"), "test");

            AggregateBars target1 = new AggregateBars(data, symbol,
                                                      new Scale(ScaleEnum.sec, 10));

            Assert.AreEqual(target1.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 35)),
                            new DateTime(2010, 09, 16, 12, 39, 30));

            Assert.AreEqual(target1.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 20)),
                            new DateTime(2010, 09, 16, 12, 39, 20));


            AggregateBars target2 = new AggregateBars(data, symbol,
                                                      new Scale(ScaleEnum.sec, 1));

            Assert.AreEqual(target2.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 35)),
                            new DateTime(2010, 09, 16, 12, 39, 35));

            Assert.AreEqual(target2.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 25)),
                            new DateTime(2010, 09, 16, 12, 39, 25));

            AggregateBars target3 = new AggregateBars(data, symbol,
                                                      new Scale(ScaleEnum.sec, 60));

            Assert.AreEqual(target3.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 35)),
                            new DateTime(2010, 09, 16, 12, 39, 0));

            Assert.AreEqual(target3.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 0)),
                            new DateTime(2010, 09, 16, 12, 39, 0));
        }
        public void TimeAlignmentTest()
        {
            IDataManager data = new Data();
            ISymbol symbol = new Symbol(data.GetMarket("testMarket"),"test");

            AggregateBars target1 = new AggregateBars(data, symbol,
                                                 new Scale(ScaleEnum.sec, 10));

            Assert.AreEqual(target1.TimeAlignment(new DateTime(2010,09,16,12,39,35)) ,
                                                 new DateTime(2010,09,16,12,39,30));

            Assert.AreEqual(target1.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 20)),
                                                 new DateTime(2010, 09, 16, 12, 39, 20));

            AggregateBars target2 = new AggregateBars(data, symbol,
                                                 new Scale(ScaleEnum.sec, 1));

            Assert.AreEqual(target2.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 35)),
                                                 new DateTime(2010, 09, 16, 12, 39, 35));

            Assert.AreEqual(target2.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 25)),
                                                 new DateTime(2010, 09, 16, 12, 39, 25));

            AggregateBars target3 = new AggregateBars(data, symbol,
                                                 new Scale(ScaleEnum.sec, 60));

            Assert.AreEqual(target3.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 35)),
                                                 new DateTime(2010, 09, 16, 12, 39, 0));

            Assert.AreEqual(target3.TimeAlignment(new DateTime(2010, 09, 16, 12, 39, 0)),
                                                 new DateTime(2010, 09, 16, 12, 39, 0));
        }