public void TestIndexOfTick_Repeat() { ITickData tickData = MockDataLoader.GetTickData("m0805", 20070919); int index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, true, 0); Assert.AreEqual(2416, index); index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, true, 1); Assert.AreEqual(2417, index); index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, true, 2); Assert.AreEqual(2418, index); index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, true, 3); Assert.AreEqual(2419, index); //index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, false, 0); //Assert.AreEqual(2416, index); //index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, false, 1); //Assert.AreEqual(2417, index); //index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, false, 2); //Assert.AreEqual(2418, index); //index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.092414, false, 3); //Assert.AreEqual(2419, index); //Console.WriteLine(index); //Console.WriteLine(tickData.Arr_Time[index]); //Console.WriteLine(tickData.GetBar(index)); }
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); } }
public void TestTickDataStore_Append() { TickData data = (TickData)MockDataLoader.GetTickData("m1005", 20100108); String path = TestCaseManager.GetTestCasePath(GetType(), "output_"); TickData d1 = data.SubData(0, 100); TickData d2 = data.SubData(101, data.Length - 1); TickDataStore_File_Single store = new TickDataStore_File_Single(path); store.Save(d1); TickDataStore_File_Single store2 = new TickDataStore_File_Single(path); store2.Append(d2); TickDataStore_File_Single store3 = new TickDataStore_File_Single(path); TickData data2 = store3.Load(); for (int i = 0; i < data.Length; i++) { data.BarPos = i; data2.BarPos = i; Assert.AreEqual(data.ToString(), data2.ToString()); } File.Delete(path); }
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); } }
private static CacheUtils_TradingTime GetTradingSessionCache(string code) { IList <ITradingTime> tradingSessions = MockDataLoader.GetTradingTimeList(code); CacheUtils_TradingTime cache = new CacheUtils_TradingTime(code, tradingSessions); return(cache); }
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); } }
public void TestTickDataStore_Append(string uri) { string code = "m1005"; int day = 20100108; IDataStore dataStore = DataStoreFactory.CreateDataStore(uri); ITickDataStore tickDataStore = dataStore.CreateTickDataStore(); try { TickData data = (TickData)MockDataLoader.GetTickData(code, day); TickData d1 = data.SubData(0, 100); TickData d2 = data.SubData(101, data.Length - 1); tickDataStore.Save(code, day, d1); tickDataStore.Append(code, day, d2); TickData data2 = tickDataStore.Load(code, day); AssertUtils.AssertEqual_TickData(data, data2); } finally { tickDataStore.Delete(code, day); } }
public void TestTransferTimeLineData() { IKLineData klineData = MockDataLoader.GetKLineData("m1505", 20150107, 20150107, KLinePeriod.KLinePeriod_1Minute); ITimeLineData timeLineData = DataTransfer_KLine2TimeLine.ConvertTimeLineData(klineData, 2849); AssertUtils.AssertEqual_TimeLineData("KLine2TimeLine_M05_20150107", GetType(), timeLineData); }
public void TestTickDataStore_FromBytes() { TickData data = (TickData)MockDataLoader.GetTickData("m1005", 20100108); byte[] bs = TickDataStore_File_Single.GetBytes(data); TickData data2 = TickDataStore_File_Single.FromBytes(bs, 0, bs.Length); AssertUtils.AssertEqual_TickData(data, data2); }
public void TestSplit_EndInNight() { IKLineData klineData = MockDataLoader.GetKLineData("m1505", 20150105, 20150106, KLinePeriod.KLinePeriod_1Minute); IKLineData subData = klineData.Sub(0, 570); List <SplitterResult> results = DaySplitter.Split(subData, GetTradingSessionCache("m1505")); Assert.AreEqual("20150105,0", results[0].ToString()); Assert.AreEqual("20150106,225", results[1].ToString()); }
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); }
public void TestTransfer_M01_20131202() { string code = "m01"; int date = 20131202; ITickData tickData = MockDataLoader.GetTickData(code, date); string time = "20131202,20131202.09-20131202.1015,20131202.103-20131202.113,20131202.133-20131202.15"; IList <double[]> tradingtime = ParseTradingTime(time); DataTransfer_Tick2KLine.Transfer(tickData, tradingtime, KLinePeriod.KLinePeriod_1Minute, 0, 0); }
private void AssertDaySplitter(string code, int start, int end, KLinePeriod period, string fileName) { CacheUtils_TradingTime cache = GetTradingSessionCache(code); IKLineData klineData = MockDataLoader.GetKLineData(code, start, end, period); List <SplitterResult> results = DaySplitter.Split(klineData, cache); AssertUtils.AssertEqual_List <SplitterResult>(fileName, GetType(), results); //AssertUtils.PrintKLineData(klineData); //AssertUtils.PrintLineList(results); }
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); }
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); }
public void TestIndexOfKLine() { IKLineData klineData = MockDataLoader.GetKLineData("m1505", 20141215, 20150116, KLinePeriod.KLinePeriod_1Minute); int index = TimeIndeierUtils.IndexOfTime_KLine(klineData, 20141225.090100); Assert.AreEqual(1801, index); index = TimeIndeierUtils.IndexOfTime_KLine(klineData, 20141225.090059); Assert.AreEqual(1800, index); index = TimeIndeierUtils.IndexOfTime_KLine(klineData, 20141225.090059, false); Assert.AreEqual(1801, index); }
public void TestTickDataStore_SaveLoad() { TickData data = (TickData)MockDataLoader.GetTickData("m1005", 20100108); String path = TestCaseManager.GetTestCasePath(GetType(), "output_tick_saveload"); TickDataStore_File_Single store = new TickDataStore_File_Single(path); store.Save(data); TickDataStore_File_Single store2 = new TickDataStore_File_Single(path); TickData data2 = store2.Load(); AssertUtils.AssertEqual_TickData(data, data2); File.Delete(path); }
private void TestTradingDaySaveLoad(string uri) { IDataStore dataStore = DataStoreFactory.CreateDataStore(uri); ITradingDayStore store = dataStore.CreateTradingDayStore(); List <int> codes = MockDataLoader.GetAllTradingDays(); store.Save(codes); List <int> codes2 = store.Load(); AssertUtils.AssertEqual_List_ToString(codes, codes2); store.Delete(); }
private void TestInstrumentsSaveLoad(string uri) { IDataStore dataStore = DataStoreFactory.CreateDataStore(uri); ICodeStore store = dataStore.CreateInstrumentStore(); List <CodeInfo> codes = MockDataLoader.GetAllInstruments(); store.Save(codes); List <CodeInfo> codes2 = store.Load(); AssertUtils.AssertEqual_List_ToString(codes, codes2); store.Delete(); }
public void TestTradingDaySaveLoad() { string path = TestCaseManager.GetTestCasePath(GetType(), "output_TradingDay"); List <int> tradingDays = MockDataLoader.GetAllTradingDays(); TradingDayStore_File store = new TradingDayStore_File(path); store.Save(tradingDays); TradingDayStore_File newstore = new TradingDayStore_File(path); List <int> tradingDays2 = newstore.Load(); AssertUtils.AssertEqual_List(tradingDays, tradingDays2); File.Delete(path); }
public void TestKLineDataStore_LoadByDate() { string path = TestCaseManager.GetTestCasePath(GetType(), "output_20100107_20100120"); IKLineData data = MockDataLoader.GetKLineData("m1005", 20100107, 20100120, KLinePeriod.KLinePeriod_1Minute); KLineDataStore_File_Single store = new KLineDataStore_File_Single(path); store.Save(data); KLineDataStore_File_Single store2 = new KLineDataStore_File_Single(path); IKLineData data2 = store2.Load(20100107, 20120111); AssertUtils.PrintKLineData(data2); File.Delete(path); }
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); }
public void TestIndexOfTick() { ITickData tickData = MockDataLoader.GetTickData("m1505", 20150121); int index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20150120.210116); Assert.AreEqual(147, index); tickData = MockDataLoader.GetTickData("m0805", 20070920); index = TimeIndeierUtils.IndexOfTime_Tick(tickData, 20070919.093027, true, 0); for (int i = 0; i < tickData.Length; i++) { double time = tickData.Arr_Time[i]; index = TimeIndeierUtils.IndexOfTime_Tick(tickData, time); Assert.AreEqual(time, tickData.Arr_Time[index]); } }
private void TestTradingSessionSaveLoad(string uri) { string code = "M05"; IDataStore dataStore = DataStoreFactory.CreateDataStore(uri); ITradingSessionStore store = dataStore.CreateTradingSessionStore(); try { List <TradingSession> codes = MockDataLoader.GetTradingSessions(code); store.Save(code, codes); List <TradingSession> codes2 = store.Load(code); AssertUtils.AssertEqual_List_ToString(codes, codes2); } finally { store.Delete(code); } }
public void TestSetRealTimeData() { IKLineData data = MockDataLoader.GetKLineData("m1405", 20131202, 20131205, KLinePeriod.KLinePeriod_1Minute); //IKLineData data = MockDataLoader_Long.GetKLineData("m1405", 20131202, 20131205, KLinePeriod.KLinePeriod_1Minute); KLineData_RealTime data_real = new KLineData_RealTime(data); KLineBar chart = new KLineBar(data_real, 15); data.BarPos = 15; chart.Code = "m1405"; chart.Time = 20131202.091455; chart.Start = 3745; chart.High = 3745; chart.Low = 3743; chart.End = 3743; chart.Mount = 1600; chart.Hold = 718011; data_real.ChangeCurrentBar(chart, 15); Assert.AreEqual("20131202.091455,3745,3745,3743,3743,1600,0,718011", chart.ToString()); Assert.AreEqual(chart.ToString(), data_real.ToString()); Assert.AreEqual(2, data_real.Height); //Console.WriteLine(data_real.HeightPercent); Assert.AreEqual(3745, data_real.BlockHigh); Assert.AreEqual(3743, data_real.BlockLow); Assert.AreEqual(2, data_real.BlockHeight); //Console.WriteLine(data_real.BlockHeightPercent); //Console.WriteLine(data_real.up); //Assert.AreEqual(3745, data_real.Arr_BlockHigh); // list_Height.SetTmpValue(barPos, chart.Height); //list_HeightPercent.SetTmpValue(barPos, chart.HeightPercent); //list_BlockHigh.SetTmpValue(barPos, chart.BlockHigh); //list_BlockLow.SetTmpValue(barPos, chart.BlockLow); //list_BlockHeight.SetTmpValue(barPos, chart.BlockHeight); //list_BlockHeightPercent.SetTmpValue(barPos, chart.BlockHeightPercent); //float upPercent = barPos == 0 ? // (float)NumberUtils.percent(chart.End, chart.Start) : // (float)NumberUtils.percent(chart.End, klineData.Arr_End[barPos - 1]); //list_UpPercent.SetTmpValue(barPos, upPercent); data_real.ChangeCurrentBar(null, 16); Assert.AreEqual("20131202.0915,3354,3354,3352,3353,9202,0,1717708", data_real.ToString(15)); }
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); }
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); }
private CacheUtils_TradingTime GetTradingSessionCache_Instrument(string code) { return(new CacheUtils_TradingTime(code, MockDataLoader.GetTradingTimeList(code))); }
public List <double[]> GetTradingTime(string code, int date) { return(MockDataLoader.GetTradingTime(code, date)); }