Beispiel #1
0
        private void TestKLineDataStore_Append(string uri)
        {
            string          code           = "m1005";
            KLinePeriod     period         = KLinePeriod.KLinePeriod_1Minute;
            IDataStore      dataStore      = DataStoreFactory.CreateDataStore(uri);
            IKLineDataStore klineDataStore = dataStore.CreateKLineDataStore();

            try
            {
                IKLineData klineData  = MockDataLoader.GetKLineData(code, 20100107, 20100114, period);
                IKLineData klineData2 = MockDataLoader.GetKLineData(code, 20100115, 20100120, period);

                List <IKLineData> ks = new List <IKLineData>();
                ks.Add(klineData);
                ks.Add(klineData2);
                IKLineData klineData_Merge = KLineData.Merge(ks);


                klineDataStore.Save(code, period, klineData);
                klineDataStore.Append(code, period, klineData2);

                IKLineData klineData_Merge2 = klineDataStore.LoadAll(code, period);
                AssertUtils.AssertEqual_KLineData(klineData_Merge, klineData_Merge2);
            }
            finally
            {
                klineDataStore.Delete(code, period);
            }
        }
Beispiel #2
0
        private void TestKLineDataStore_LoadByDate(string uri)
        {
            string          code           = "m1005";
            KLinePeriod     klinePeriod    = KLinePeriod.KLinePeriod_1Minute;
            IDataStore      dataStore      = DataStoreFactory.CreateDataStore(uri);
            IKLineDataStore klineDataStore = dataStore.CreateKLineDataStore();

            try
            {
                IKLineData data = MockDataLoader.GetKLineData(code, 20100107, 20100120, klinePeriod);
                klineDataStore.Save(code, klinePeriod, data);

                IKLineData        klineData  = klineDataStore.Load(code, 20100107, 20100111, klinePeriod);
                IKLineData        klineData2 = klineDataStore.Load(code, 20100112, 20100120, klinePeriod);
                List <IKLineData> ks         = new List <IKLineData>();
                ks.Add(klineData);
                ks.Add(klineData2);
                IKLineData klineData_Merge = KLineData.Merge(ks);

                //AssertUtils.PrintKLineData(data);
                //AssertUtils.PrintKLineData(klineData_Merge);
                AssertUtils.PrintKLineData(klineData);
                //AssertUtils.PrintKLineData(klineData_Merge);
                AssertUtils.AssertEqual_KLineData(data, klineData_Merge);
            }
            finally
            {
                klineDataStore.Delete(code, klinePeriod);
            }
        }
Beispiel #3
0
        private void TestKLineDataStore_SaveLoad(string uri)
        {
            string          code           = "m1005";
            KLinePeriod     period         = KLinePeriod.KLinePeriod_1Minute;
            IDataStore      dataStore      = DataStoreFactory.CreateDataStore(uri);
            IKLineDataStore klineDataStore = dataStore.CreateKLineDataStore();

            try
            {
                IKLineData klineData = MockDataLoader.GetKLineData(code, 20100107, 20100120, period);

                klineDataStore.Save(code, period, klineData);

                KLineData klineData2 = klineDataStore.LoadAll(code, period);
                AssertUtils.AssertEqual_KLineData(klineData, klineData2);

                Assert.AreEqual(20100107, klineDataStore.GetFirstTradingDay(code, period));
                Assert.AreEqual(20100120, klineDataStore.GetLastTradingDay(code, period));
                Console.WriteLine(klineDataStore.GetLastTradingTime(code, period));
            }
            finally
            {
                klineDataStore.Delete(code, period);
            }
        }
Beispiel #4
0
        private void TestKLineData_GetData(string code, int start, int end, KLinePeriod period, string fileName)
        {
            IDataReader dataReader = DataReaderFactory.CreateDataReader(DataCenterUri.URI);
            IKLineData  klineData  = dataReader.KLineDataReader.GetData(code, start, end, period);

            //AssertUtils.PrintKLineData(klineData);
            AssertUtils.AssertEqual_KLineData(fileName, GetType(), klineData);
        }
Beispiel #5
0
        private void TestKLineData_GetData(string code, int start, int end, KLinePeriod period, string fileName)
        {
            IDataReader dataReader = DataCenter.Default.DataReader;
            IKLineData  klineData  = dataReader.KLineDataReader.GetData(code, start, end, period);

            AssertUtils.PrintKLineData(klineData);
            AssertUtils.AssertEqual_KLineData(fileName, GetType(), klineData);
        }
        public void TestTransferKLine_DayOverNight()
        {
            string                 code      = "m1505";
            IKLineData             klineData = MockDataLoader.GetKLineData(code, 20141215, 20150116, KLinePeriod.KLinePeriod_1Minute);
            CacheUtils_TradingTime cache     = new CacheUtils_TradingTime(code, MockDataLoader.GetTradingTimeList(code));
            IKLineData             data      = DataTransfer_KLine2KLine.Transfer_Day(klineData, new KLinePeriod(KLineTimeType.DAY, 1), cache);

            AssertUtils.AssertEqual_KLineData("Kline2Kline_M05_20141215_20150116_Day", GetType(), data);
        }
        public void TestTransferKLine_Day()
        {
            string                 code      = "m1405";
            IKLineData             data_1min = MockDataLoader.GetKLineData(code, 20131216, 20131231, new KLinePeriod(KLineTimeType.MINUTE, 1));
            CacheUtils_TradingTime cache     = new CacheUtils_TradingTime(code, MockDataLoader.GetTradingTimeList(code));
            IKLineData             data      = DataTransfer_KLine2KLine.Transfer_Day(data_1min, new KLinePeriod(KLineTimeType.DAY, 1), cache);

            AssertUtils.AssertEqual_KLineData("Kline2kline_M05_20131216_20131231_Day", GetType(), data);
        }
Beispiel #8
0
        public void TestTransferNight()
        {
            string           code        = "m1505";
            int              date        = 20150107;
            ITickData        tickData    = MockDataLoader.GetTickData(code, date);
            string           time        = "20150107,20150106.21-20150107.023,20150107.09-20150107.1015,20150107.103-20150107.113,20150107.133-20150107.15";
            IList <double[]> tradingtime = ParseTradingTime(time);
            IKLineData       klineData   = DataTransfer_Tick2KLine.Transfer(tickData, tradingtime, KLinePeriod.KLinePeriod_1Minute, -1, -1);

            AssertUtils.AssertEqual_KLineData("Tick2KLine_M05_20150107", GetType(), klineData);
        }
Beispiel #9
0
        public void TestTransfer_M05_20040630()
        {
            string           code        = "m0505";
            int              date        = 20040630;
            ITickData        tickData    = MockDataLoader.GetTickData(code, date);
            string           time        = "20040630,20040630.09-20040630.1015,20040630.103-20040630.113,20040630.133-20040630.15";
            IList <double[]> tradingtime = ParseTradingTime(time);
            IKLineData       data        = DataTransfer_Tick2KLine.Transfer(tickData, tradingtime, KLinePeriod.KLinePeriod_1Minute, 2626, -1);

            AssertUtils.AssertEqual_KLineData("Tick2KLine_M05_20040630", GetType(), data);
        }
Beispiel #10
0
        public void TestGetKLineExtend_Second()
        {
            IDataReader       dataReader = DataCenter.Default.DataReader;
            IKLineData_Extend klineData  = dataReader.KLineDataReader.GetData_Extend("rb1801", 20170801, KLinePeriod.KLinePeriod_5Second);

            //AssertUtils.PrintKLineData(klineData);
            AssertUtils.AssertEqual_KLineData("KLineData_RB1801_20170801_5Second", GetType(), klineData);

            klineData = dataReader.KLineDataReader.GetData_Extend("rb1801", 20170801, KLinePeriod.KLinePeriod_15Second);
            //AssertUtils.PrintKLineData(klineData);
            AssertUtils.AssertEqual_KLineData("KLineData_RB1801_20170801_15Second", GetType(), klineData);
        }
Beispiel #11
0
        public void TestKLineDataStore_SaveLoad()
        {
            IKLineData klineData = MockDataLoader.GetKLineData("m1005", 20100107, 20100120, KLinePeriod.KLinePeriod_1Minute);

            String path = TestCaseManager.GetTestCasePath(GetType(), "output_20100107_20100120");
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(klineData);

            KLineDataStore_File_Single store2 = new KLineDataStore_File_Single(path);
            KLineData klineData2 = store.LoadAll();

            AssertUtils.AssertEqual_KLineData(klineData, klineData2);
            File.Delete(path);
        }
Beispiel #12
0
        public void TestKLineDataSaveLoad()
        {
            String filename = "KLineData_Output.csv";

            string[]   lines     = TestCaseManager.LoadTestCaseFile(GetType(), "CsvUtils_KLineData").Split('\r');
            IKLineData klineData = CsvUtils_KLineData.LoadByLines(lines);

            string testCasePath = TestCaseManager.GetTestCasePath(GetType(), filename);

            CsvUtils_KLineData.Save(testCasePath, klineData);
            IKLineData newklineData = CsvUtils_KLineData.Load(testCasePath);

            File.Delete(testCasePath);

            AssertUtils.AssertEqual_KLineData(klineData, newklineData);
        }
Beispiel #13
0
 private void AssertKLineDataInDic(string code, int start, int endDate)
 {
     foreach (KLinePeriod period in dic_Period_Content.Keys)
     {
         List <string> contents = dic_Period_Content[period];
         StringBuilder sb       = new StringBuilder();
         for (int i = 0; i < contents.Count; i++)
         {
             if (i != 0)
             {
                 sb.Append("\r\n");
             }
             sb.Append(contents[i]);
         }
         IKLineData klineData = DataCenter.Default.DataReader.KLineDataReader.GetData(code, start, endDate, period);
         AssertUtils.AssertEqual_KLineData(sb.ToString(), klineData);
     }
 }
        public void TestTransferKLine_Minute()
        {
            string                 code        = "m1405";
            int                    start       = 20131216;
            int                    end         = 20131231;
            List <double[]>        tradingTime = MockDataLoader.GetTradingTime(code, start);
            IKLineData             data_1min   = MockDataLoader.GetKLineData(code, start, end, KLinePeriod.KLinePeriod_1Minute);
            CacheUtils_TradingTime cache       = new CacheUtils_TradingTime(code, MockDataLoader.GetTradingTimeList(code));

            //转换成5分钟线
            IKLineData data = DataTransfer_KLine2KLine.Transfer(data_1min, KLinePeriod.KLinePeriod_5Minute, cache);

            AssertUtils.AssertEqual_KLineData("Kline2Kline_M05_20131216_20131231_5Minute", GetType(), data);

            //转换成15分钟
            data = DataTransfer_KLine2KLine.Transfer(data_1min, new KLinePeriod(KLineTimeType.MINUTE, 15), cache);
            AssertUtils.AssertEqual_KLineData("Kline2Kline_M05_20131216_20131231_15Minute", GetType(), data);

            //转换成1小时
            data = DataTransfer_KLine2KLine.Transfer(data_1min, new KLinePeriod(KLineTimeType.HOUR, 1), cache);
            AssertUtils.AssertEqual_KLineData("Kline2Kline_M05_20131216_20131231_1Hour", GetType(), data);
        }
Beispiel #15
0
        public void TestKLineDataStore_Append()
        {
            IKLineData klineData  = MockDataLoader.GetKLineData("m1005", 20100107, 20100114, KLinePeriod.KLinePeriod_1Minute);
            IKLineData klineData2 = MockDataLoader.GetKLineData("m1005", 20100115, 20100120, KLinePeriod.KLinePeriod_1Minute);

            List <IKLineData> ks = new List <IKLineData>();

            ks.Add(klineData);
            ks.Add(klineData2);
            IKLineData klineData_Merge = KLineData.Merge(ks);

            String path = TestCaseManager.GetTestCasePath(GetType(), "output_append");
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(klineData);
            store.Append(klineData2);

            IKLineData klineData_Merge2 = store.LoadAll();

            AssertUtils.AssertEqual_KLineData(klineData_Merge, klineData_Merge2);

            File.Delete(path);
        }