コード例 #1
0
        public void test_buildAndUpdateSynMinuteBar_negative()
        {
            DateTime  time1    = new DateTime(2015, 10, 21, 10, 0, 5, DateTimeKind.Local);
            IBMessage message1 = createMessage_for_isRTBarProcessStart_Open(time1);

            //[Test: invalid initial action test, currentTempRTBar is null, currentCompleteRTBar is null and the time is not in 0 second.]
            AppMDManager appMDManager = createManager_buildAndUpdateSynMinuteBar_begin();

            appMDManager.buildAndUpdateSynMinuteBar(message1);
            Assert.IsNull(appMDManager.currentTempRTBar);
            Assert.IsNull(appMDManager.currentCompleteRTBar);
        }
コード例 #2
0
        public void test_buildAndUpdateSynMinuteBar_normal()
        {
            DateTime time1 = new DateTime(2015, 10, 21, 10, 0, 0, DateTimeKind.Local);
            DateTime time2 = new DateTime(2015, 10, 21, 10, 0, 5, DateTimeKind.Local);
            DateTime time3 = new DateTime(2015, 10, 21, 10, 0, 10, DateTimeKind.Local);
            DateTime time4 = new DateTime(2015, 10, 21, 10, 0, 55, DateTimeKind.Local);
            DateTime time5 = new DateTime(2015, 10, 21, 10, 1, 0, DateTimeKind.Local);

            IBMessage message1 = createMessage_for_isRTBarProcessStart_Open(time1);
            IBMessage message2 = createMessage_for_isRTBarProcessStart_High(time2);
            IBMessage message3 = createMessage_for_isRTBarProcessStart_Low(time3);
            IBMessage message4 = createMessage_for_isRTBarProcessStart_Close(time4);
            IBMessage message5 = createMessage_for_isRTBarProcessStart_Open(time5);

            //[Test: initial action test, currentTempRTBar is null, currentCompleteRTBar is null and the time is in 0 second.]
            AppMDManager appMDManager = createManager_buildAndUpdateSynMinuteBar_begin();

            appMDManager.buildAndUpdateSynMinuteBar(message1);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.open);
            Assert.AreEqual(20200, appMDManager.currentTempRTBar.high);
            Assert.AreEqual(20000, appMDManager.currentTempRTBar.low);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.close);
            Assert.AreEqual(time1, appMDManager.currentTempRTBar.time);
            Assert.IsNull(appMDManager.currentCompleteRTBar);

            //[Test: make a new high synthesis test, high is a new high, and the time is not in 0 second.]
            appMDManager.buildAndUpdateSynMinuteBar(message2);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.open);
            Assert.AreEqual(20250, appMDManager.currentTempRTBar.high);
            Assert.AreEqual(20000, appMDManager.currentTempRTBar.low);
            Assert.AreEqual(20105, appMDManager.currentTempRTBar.close);
            Assert.AreEqual(time1, appMDManager.currentTempRTBar.time);
            Assert.IsNull(appMDManager.currentCompleteRTBar);

            //[Test: make a new low synthesis test, low is a new low, and the time is not in 0 second.]
            appMDManager.buildAndUpdateSynMinuteBar(message3);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.open);
            Assert.AreEqual(20250, appMDManager.currentTempRTBar.high);
            Assert.AreEqual(19990, appMDManager.currentTempRTBar.low);
            Assert.AreEqual(20110, appMDManager.currentTempRTBar.close);
            Assert.AreEqual(time1, appMDManager.currentTempRTBar.time);
            Assert.IsNull(appMDManager.currentCompleteRTBar);

            //[Test: close minute test, the time is in 55 second.]
            appMDManager.buildAndUpdateSynMinuteBar(message4);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.open);
            Assert.AreEqual(20250, appMDManager.currentTempRTBar.high);
            Assert.AreEqual(19990, appMDManager.currentTempRTBar.low);
            Assert.AreEqual(20155, appMDManager.currentTempRTBar.close);
            Assert.AreEqual(time1, appMDManager.currentTempRTBar.time);
            Assert.AreEqual(20100, appMDManager.currentCompleteRTBar.open);
            Assert.AreEqual(20250, appMDManager.currentCompleteRTBar.high);
            Assert.AreEqual(19990, appMDManager.currentCompleteRTBar.low);
            Assert.AreEqual(20155, appMDManager.currentCompleteRTBar.close);
            Assert.AreEqual(time1, appMDManager.currentCompleteRTBar.time);

            //[Test: open minute test, the time is in 55 second.]
            appMDManager.buildAndUpdateSynMinuteBar(message5);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.open);
            Assert.AreEqual(20200, appMDManager.currentTempRTBar.high);
            Assert.AreEqual(20000, appMDManager.currentTempRTBar.low);
            Assert.AreEqual(20100, appMDManager.currentTempRTBar.close);
            Assert.AreEqual(time5, appMDManager.currentTempRTBar.time);
            Assert.IsNull(appMDManager.currentCompleteRTBar);
        }