Esempio n. 1
0
        public void TestTradingSession_GetTradingDay()
        {
            ITradingTimeReader_Code reader = GetTradingSessionCache_Instrument("m1405");
            int date = reader.GetTradingDay(20140505.092000);

            Assert.AreEqual(20140505, date);

            date = reader.GetTradingDay(20140505.082000);
            Assert.AreEqual(-1, date);

            date = reader.GetRecentTradingDay(20140505.082000);
            Assert.AreEqual(20140430, date);

            date = reader.GetRecentTradingDay(20140505.192000);
            Assert.AreEqual(20140505, date);

            reader = GetTradingSessionCache_Instrument("m1605");
            date   = reader.GetTradingDay(20150717.220000);
            Assert.AreEqual(20150720, date);

            date = reader.GetTradingDay(20150718.220000);
            Assert.AreEqual(20150720, date);

            date = reader.GetRecentTradingDay(20150816.100000, true);
            Assert.AreEqual(20150817, date);

            date = reader.GetRecentTradingDay(20150816.100000, false);
            Assert.AreEqual(20150817, date);

            date = reader.GetRecentTradingDay(20150816.100000, false);
            Assert.AreEqual(20150817, date);

            date = reader.GetRecentTradingDay(20150814.160000, true);
            Assert.AreEqual(20150817, date);

            date = reader.GetRecentTradingDay(20150814.160000, false);
            Assert.AreEqual(20150814, date);

            date = reader.GetRecentTradingDay(30150718.220000);
            Assert.AreEqual(20160520, date);

            reader = GetTradingSessionCache_Instrument("m1705");
            date   = reader.GetRecentTradingDay(20170130.10, false);
            Assert.AreEqual(20170126, date);
            date = reader.GetRecentTradingDay(20170130.10);
            Assert.AreEqual(20170126, date);

            reader = GetTradingSessionCache_Instrument("m0405");
            date   = reader.GetRecentTradingDay(10150718.220000);
            Assert.AreEqual(-1, date);

            reader = GetTradingSessionCache_Instrument("RB1805");
            date   = reader.GetRecentTradingDay(20171221.2101);
            Assert.AreEqual(20171222, date);
        }
Esempio n. 2
0
        public void TestGetTradingDay()
        {
            ITradingTimeReader_Code reader = GetTradingSessionCache_Instrument("M1305");
            int day = reader.GetTradingDay(20130105.093000);

            Assert.AreEqual(-1, day);
            day = reader.GetTradingDay(20130108.090000);
            Assert.AreEqual(20130108, day);
            day = reader.GetTradingDay(20130108.085900);
            Assert.AreEqual(-1, day);
        }
Esempio n. 3
0
        /// <summary>
        /// 返回一个整型数组的list
        /// 整型数组第一项是日期,第二项是index
        /// </summary>
        /// <param name="timeGetter"></param>
        /// <returns></returns>
        public static List <SplitterResult> Split(TimeGetter timeGetter, ITradingTimeReader_Code tradingSessionReader)
        {
            List <SplitterResult> indeies = new List <SplitterResult>(500);
            double time = timeGetter.GetTime(0);
            int    date = tradingSessionReader.GetTradingDay(time);

            indeies.Add(new SplitterResult(date, 0));
            for (int index = 1; index < timeGetter.Count; index++)
            {
                time = timeGetter.GetTime(index);
                if (tradingSessionReader.IsStartTime(time))
                {
                    date = tradingSessionReader.GetTradingDay(time);
                    indeies.Add(new SplitterResult(date, index));
                }
            }
            return(indeies);
        }