public void TestNavigate() { string code = "rb1705"; double time = 20170405.093001; IDataNavigate dataNavigate = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time); Assert.AreEqual("20170405.093001,3470,3470,3470,3470,272,943840,731414", dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString()); time = 20170405.093058; bool canNav = dataNavigate.NavigateTo(time); Assert.IsTrue(canNav); Assert.AreEqual("20170405.093058,3470,3470,3463,3463,1062,3681108,731424", dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString()); time = 20170405.093059; canNav = dataNavigate.NavigateTo(time); Assert.IsTrue(canNav); string str = "20170405.093,3470,3470,3463,3463,1062,0,731424"; Assert.AreEqual(str, dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString()); dataNavigate.Change("rb1710"); Console.WriteLine(dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute)); Assert.AreEqual("20170405.093059,3260,3262,3252,3252,33892,1.104346E+08,2476612", dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString()); dataNavigate.Change("rb1705"); Assert.AreEqual(str, getKLineBar(dataNavigate)); bool canForward = dataNavigate.Forward(KLinePeriod.KLinePeriod_5Minute); Console.WriteLine(getKLineBar(dataNavigate)); dataNavigate.NavigateTo(20160603.093000); Console.WriteLine(dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute)); }
private void CurrentNavigater_OnNavigateTo(object sender, data.navigate.DataNavigateEventArgs e) { this.prevChartComponentData.CopyFrom(this.chartComponentData); this.ChartComponentData.Change(e.Code, e.Time); this.ChartComponentData.ChangeKLineIndex(currentNavigater.GetKLineData(ChartComponentData.KlinePeriod).BarPos); if (this.OnDataChanged != null) { this.OnDataChanged(this, new ChartComponentDataChangeArgument(prevChartComponentData, ChartComponentData)); } }
public void Init(IDataCenter dataCenter, string code, double time, KLinePeriod klinePeriod) { this.dataCenter = dataCenter; IDataNavigate dataNavigater = dataCenter.DataNavigateFactory.CreateDataNavigate(code, time); IKLineData klineData = dataNavigater.GetKLineData(klinePeriod); int showKLineIndex = klineData.BarPos; ChartComponentData compData = new ChartComponentData(code, time, klinePeriod, showKLineIndex); this.controller = new ChartComponentController(dataNavigater, compData); this.drawer = new ChartComponentDrawer(this, controller); //this.drawer.GraphicData_Candle.OnGraphicDataChange += GraphicData_Candle_OnGraphicDataChange; this.drawer.GraphicDrawer.AfterGraphicPaint += GraphicDrawer_AfterGraphicPaint; }
public FormChartComponentDrawer() { InitializeComponent(); string code = "rb1710"; double time = 20170601.093055; KLinePeriod klinePeriod = KLinePeriod.KLinePeriod_1Minute; IDataNavigate dataNavigater = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time); IKLineData klineData = dataNavigater.GetKLineData(klinePeriod); int showKLineIndex = klineData.BarPos; ChartComponentData compData = new ChartComponentData(code, time, klinePeriod, showKLineIndex); controller = new ChartComponentController(dataNavigater, compData); ChartComponentDrawer drawer = new ChartComponentDrawer(this, controller); //drawer.RePaint(); }
public void TestController() { string code = "rb1710"; double time = 20170601.093055; KLinePeriod klinePeriod = KLinePeriod.KLinePeriod_1Minute; IDataNavigate dataNavigater = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time); IKLineData klineData = dataNavigater.GetKLineData(klinePeriod); int showKLineIndex = klineData.BarPos; ChartComponentData compData = new ChartComponentData(code, time, klinePeriod, showKLineIndex); ChartComponentController controller = new ChartComponentController(dataNavigater, compData); IRealTimeData_Code reader = controller.CurrentRealTimeDataReader_Code; IKLineData currentKLine = reader.GetKLineData(klinePeriod); Assert.AreEqual(compData.Code, currentKLine.Code); Assert.AreEqual(compData.Time, currentKLine.Time); Assert.AreEqual(compData.ShowKLineIndex, currentKLine.BarPos); Console.WriteLine(currentKLine); controller.Change("rb1801"); currentKLine = reader.GetKLineData(klinePeriod); Assert.AreEqual(compData.Code, currentKLine.Code); Assert.AreEqual(compData.Time, currentKLine.Time); Assert.AreEqual(compData.ShowKLineIndex, currentKLine.BarPos); Console.WriteLine(currentKLine); controller.Change(code); currentKLine = reader.GetKLineData(klinePeriod); Assert.AreEqual(compData.Code, currentKLine.Code); Assert.AreEqual(compData.Time, currentKLine.Time); Assert.AreEqual(compData.ShowKLineIndex, currentKLine.BarPos); Console.WriteLine(currentKLine); controller.ChangeChartType(ChartType.TimeLine); Console.WriteLine(compData); controller.Change(20170601.100531); controller.ChangeChartType(ChartType.KLine); Console.WriteLine(reader.GetKLineData(compData.KlinePeriod)); Console.WriteLine(compData); controller.Change("rb1801", 20171014.093000, KLinePeriod.KLinePeriod_1Minute); Console.WriteLine(compData); }
public void TestPlay() { string code = "rb1710"; double time = 20170601.093055; IDataNavigate dataNavigater = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time); KLinePeriod klinePeriod = KLinePeriod.KLinePeriod_1Minute; IKLineData klineData = dataNavigater.GetKLineData(klinePeriod); int showKLineIndex = klineData.BarPos; ChartComponentData compData = new ChartComponentData(code, time, klinePeriod, showKLineIndex); ChartComponentController controller = new ChartComponentController(dataNavigater, compData); controller.OnDataChanged += Controller_OnDataChanged; //controller.Play(); //while (controller.IsPlayIng) //{ //} //while(time<2017) }
private static string getKLineBar(IDataNavigate dataNavigate) { return dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString(); }