Exemple #1
0
        private IAppRTBSynchronizer getSynchronizer_for_updatePreMergeRTBarSeries()
        {
            Series <DateTime, MarketDataElement> preMergeRTBarSeries   = null;
            Series <DateTime, MarketDataElement> preMergeHistBarSeries = null;
            Series <DateTime, MarketDataElement> TimeBarSeries         = null;

            DateTime RTBTime1 = new DateTime(2015, 10, 21, 9, 20, 0, DateTimeKind.Local);
            DateTime RTBTime2 = new DateTime(2015, 10, 21, 9, 21, 0, DateTimeKind.Local);
            DateTime RTBTime3 = new DateTime(2015, 10, 21, 9, 22, 0, DateTimeKind.Local);

            preMergeRTBarSeries = addMarketDataElementWithTimeOnlyToSeries(RTBTime1, preMergeRTBarSeries);
            preMergeRTBarSeries = addMarketDataElementWithTimeOnlyToSeries(RTBTime2, preMergeRTBarSeries);
            preMergeRTBarSeries = addMarketDataElementWithTimeOnlyToSeries(RTBTime3, preMergeRTBarSeries);

            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.setTimeBarSeries(TimeBarSeries);
            appMDManager.setRtbDataStartTime(RTBTime1);

            IAppRTBSynchronizer synchronizer = appMDManager.getAppRTBSynchronizer();

            synchronizer.preMergeHistBarSeries = preMergeHistBarSeries;
            synchronizer.preMergeRTBarSeries   = preMergeRTBarSeries;
            synchronizer.setNeedMergeFlag(true);
            synchronizer.setIsDataMerged(false);
            return(synchronizer);
        }
Exemple #2
0
        AppMDManager createManager_buildAndUpdateSynMinuteBar_begin()
        {
            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.currentCompleteRTBar = null;
            appMDManager.currentTempRTBar     = null;
            return(appMDManager);
        }
Exemple #3
0
        public void test_isDataReady_negative2()
        {
            //[Test: non-syn action and data not ready case, synchronizer.getIsDataMerged is false, synchronizer.getNeedMergeFlag is false, Timeseries is null.]
            IAppRTBSynchronizer synchronizer = getAppRTBSynchronizer_for_isDataReady_negative2();
            AppMDManager        appMDManager = new AppMDManager(null);

            appMDManager.injectAppRTBSynchronizer(synchronizer);
            Assert.IsFalse(appMDManager.isDataReady());
        }
Exemple #4
0
        public void test_isDataReady_positive1()
        {
            //[Test: need syn action and data ready case, synchronizer.getIsDataMerged is true, synchronizer.getNeedMergeFlag is true.]
            IAppRTBSynchronizer synchronizer = getAppRTBSynchronizer_for_isDataReady_positive1();
            AppMDManager        appMDManager = new AppMDManager(null);

            appMDManager.injectAppRTBSynchronizer(synchronizer);
            Assert.IsTrue(appMDManager.isDataReady());
        }
Exemple #5
0
        private IAppMDManager getAppRTBSynchronizer_for_reqHistDataIfValid(DateTime dt)
        {
            IAppMDManager appMDManager = new AppMDManager(new IBTradeApp());

            appMDManager.setRtbDataStartTime(dt);
            IIBTradeAppBridge mock = new IBTradeAppMock();

            appMDManager.injectParentUI(mock);
            return(appMDManager);
        }
Exemple #6
0
        public void test_updateRTBarSeriesActions_init()
        {
            //[Test: Init Case, TimeBarSeries is null and currentCompleteRTB is not null]
            DateTime     time1        = new DateTime(2015, 10, 21, 10, 0, 0, DateTimeKind.Local);
            AppMDManager appMDManager = createManager_updateRTBarSeriesActions_init(time1);

            appMDManager.updateRTBarSeriesActions();
            MarketDataElement element = appMDManager.getTimeBarSeries().Get(time1);

            Assert.AreEqual(time1, element.time);
            Assert.AreEqual(1, appMDManager.getTimeBarSeries().KeyCount);
        }
Exemple #7
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);
        }
Exemple #8
0
        AppMDManager createManager_updateRTBarSeriesActions_cont_negative(DateTime dt1, DateTime dt2)
        {
            RTDataBar currentCompleteBar = null;
            Series <DateTime, MarketDataElement> series = null;

            series = addMarketDataElementWithTimeOnlyToSeries(dt1, series);
            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.currentCompleteRTBar = currentCompleteBar;
            appMDManager.currentTempRTBar     = null;
            appMDManager.setTimeBarSeries(series);
            return(appMDManager);
        }
Exemple #9
0
        public void test_updateRTBarSeriesActions_cont_negative()
        {
            //[Test: Continuou Case, TimeBarSeries is not null and currentCompleteRTB is not null]
            DateTime     time1        = new DateTime(2015, 10, 21, 10, 0, 0, DateTimeKind.Local);
            DateTime     time2        = new DateTime(2015, 10, 21, 10, 1, 0, DateTimeKind.Local);
            AppMDManager appMDManager = createManager_updateRTBarSeriesActions_cont_negative(time1, time2);

            appMDManager.updateRTBarSeriesActions();
            MarketDataElement element1 = appMDManager.getTimeBarSeries().Get(time1);

            Assert.AreEqual(time1, element1.time);
            Assert.AreEqual(1, appMDManager.getTimeBarSeries().KeyCount);
        }
Exemple #10
0
        public void test_isDataReady_positive2()
        {
            DateTime time1 = new DateTime(2015, 10, 21, 10, 0, 5, DateTimeKind.Local);
            //[Test: non-syn action and data ready case, synchronizer.getIsDataMerged is false, synchronizer.getNeedMergeFlag is false, Timeseries is not null.]
            Series <DateTime, MarketDataElement> TimeSeries = null;

            TimeSeries = addMarketDataElementWithTimeOnlyToSeries(time1, TimeSeries);

            IAppRTBSynchronizer synchronizer = getAppRTBSynchronizer_for_isDataReady_positive2();
            AppMDManager        appMDManager = new AppMDManager(null);

            appMDManager.injectAppRTBSynchronizer(synchronizer);
            appMDManager.setTimeBarSeries(TimeSeries);
            Assert.IsTrue(appMDManager.isDataReady());
        }
Exemple #11
0
        public void test_checkIsRTBarMergeNeed_negative2()
        {
            //[Test: non-initial and negative case, initFlag is true and isRTBarMergeNeed is false => initFlag is true, getIsRTBarMergeNeed is false]
            IAppRTBSynchronizer synchronizer = getSyn_checkIsRTBarMergeNeed();
            AppMDManager        appMDManager = new AppMDManager(null);

            appMDManager.injectRTBInitFlag(true);
            TickerInfo info = new TickerInfo();

            info.startTime = "false";
            appMDManager.injectAppRTBSynchronizer(synchronizer);
            appMDManager.tickerInfo = info;
            appMDManager.checkIsRTBarMergeNeed();
            Assert.IsTrue(appMDManager.getRTBInitFlag());
            Assert.IsFalse(appMDManager.getIsRTBarMergeNeed());
        }
Exemple #12
0
        private IAppRTBSynchronizer getSynchronizer_for_mergeRTBHistDataIfValid_positive3()
        {
            Series <DateTime, MarketDataElement> preMergeRTBarSeries   = null;
            Series <DateTime, MarketDataElement> preMergeHistBarSeries = null;
            Series <DateTime, MarketDataElement> TimeBarSeries         = null;

            DateTime histTime1 = new DateTime(2015, 10, 21, 9, 15, 0, DateTimeKind.Local);
            DateTime histTime2 = new DateTime(2015, 10, 21, 9, 16, 0, DateTimeKind.Local);
            DateTime histTime3 = new DateTime(2015, 10, 21, 9, 17, 0, DateTimeKind.Local);
            DateTime histTime4 = new DateTime(2015, 10, 21, 9, 18, 0, DateTimeKind.Local);
            DateTime histTime5 = new DateTime(2015, 10, 21, 9, 21, 0, DateTimeKind.Local);
            DateTime histTime6 = new DateTime(2015, 10, 21, 9, 22, 0, DateTimeKind.Local);
            DateTime histTime7 = new DateTime(2015, 10, 21, 9, 23, 0, DateTimeKind.Local);
            DateTime histTime8 = new DateTime(2015, 10, 21, 9, 24, 0, DateTimeKind.Local);

            DateTime RTBTime1 = new DateTime(2015, 10, 21, 9, 24, 0, DateTimeKind.Local);
            DateTime RTBTime2 = new DateTime(2015, 10, 21, 9, 25, 0, DateTimeKind.Local);
            DateTime RTBTime3 = new DateTime(2015, 10, 21, 9, 26, 0, DateTimeKind.Local);


            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime1, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime2, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime3, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime4, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime5, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime6, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime7, preMergeHistBarSeries);
            preMergeHistBarSeries = addMarketDataElementWithTimeOnlyToSeries(histTime8, preMergeHistBarSeries);

            preMergeRTBarSeries = addMarketDataElementWithTimeOnlyToSeries(RTBTime1, preMergeRTBarSeries);
            preMergeRTBarSeries = addMarketDataElementWithTimeOnlyToSeries(RTBTime2, preMergeRTBarSeries);
            preMergeRTBarSeries = addMarketDataElementWithTimeOnlyToSeries(RTBTime3, preMergeRTBarSeries);

            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.setTimeBarSeries(TimeBarSeries);
            appMDManager.setRtbDataStartTime(RTBTime1);
            appMDManager.setHistDataEndTime(histTime7);
            IAppRTBSynchronizer synchronizer = appMDManager.getAppRTBSynchronizer();

            synchronizer.preMergeHistBarSeries = preMergeHistBarSeries;
            synchronizer.preMergeRTBarSeries   = preMergeRTBarSeries;
            synchronizer.setNeedMergeFlag(true);
            synchronizer.setIsDataMerged(false);
            return(synchronizer);
        }
Exemple #13
0
        AppMDManager createManager_updateRTBarSeriesActions_init(DateTime dt)
        {
            RTDataBar currentCompleteBar = new RTDataBar();

            currentCompleteBar.time   = dt;
            currentCompleteBar.open   = 20100;
            currentCompleteBar.close  = 20100;
            currentCompleteBar.high   = 20200;
            currentCompleteBar.low    = 20000;
            currentCompleteBar.volume = 500;

            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.currentCompleteRTBar = currentCompleteBar;
            appMDManager.currentTempRTBar     = null;
            return(appMDManager);
        }
Exemple #14
0
        AppMDManager createManager_updateRTBarSeriesActions_cont(DateTime dt1, DateTime dt2)
        {
            RTDataBar currentCompleteBar = new RTDataBar();

            currentCompleteBar.time   = dt2;
            currentCompleteBar.open   = 20100;
            currentCompleteBar.close  = 20100;
            currentCompleteBar.high   = 20200;
            currentCompleteBar.low    = 20000;
            currentCompleteBar.volume = 500;

            Series <DateTime, MarketDataElement> series = null;

            series = addMarketDataElementWithTimeOnlyToSeries(dt1, series);
            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.currentCompleteRTBar = currentCompleteBar;
            appMDManager.currentTempRTBar     = null;
            appMDManager.setTimeBarSeries(series);
            return(appMDManager);
        }
Exemple #15
0
        public void test_isRTBarProcessStart()
        {
            //[Test: return ture, RTBDataStartTime is invalid Time and the message time is in 0 second.]
            DateTime     validTime    = new DateTime(2015, 11, 21, 9, 50, 0, DateTimeKind.Local);
            AppMDManager appMDManager = new AppMDManager(null);

            appMDManager.setRtbDataStartTime(AppConstant.INVALID_TIME);
            IBMessage validStartMessage = createMessage_for_isRTBarProcessStart(validTime);

            Assert.IsTrue(appMDManager.isRTBarProcessStart(validStartMessage));
            Assert.AreEqual(validTime, appMDManager.getRtbDataStartTime());

            //[Test: return false, RTBDataStartTime is invalid Time and the message time is not in 0 second.]
            DateTime invalidTime = new DateTime(2015, 11, 21, 9, 50, 5, DateTimeKind.Local);

            appMDManager = new AppMDManager(null);
            appMDManager.setRtbDataStartTime(AppConstant.INVALID_TIME);
            IBMessage invalidStartMessage = createMessage_for_isRTBarProcessStart(invalidTime);

            Assert.IsFalse(appMDManager.isRTBarProcessStart(invalidStartMessage));
            Assert.AreEqual(AppConstant.INVALID_TIME, appMDManager.getRtbDataStartTime());
        }
Exemple #16
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);
        }