Esempio n. 1
0
 private void InsertIntoHighData(float high, int barPos, int index)
 {
     for (int i = topCalCount - 1; i > index; i--)
     {
         topList[i] = topList[i - 1];
     }
     topList[index] = new KLineBarInfo(klineData.GetBar(barPos), barPos);
 }
Esempio n. 2
0
 private void PrintKLines(int mainPos, KLineToKLineIndeier indeier, IList <IKLineData_Extend> indexKLines, List <string> list_OnBar)
 {
     for (int i = 0; i < indexKLines.Count; i++)
     {
         IKLineData klineData = indexKLines[i];
         int        pos       = indeier.GetOtherKLineBarPosIfFinished(mainPos, klineData.Period);
         if (pos >= 0)
         {
             list_OnBar.Add(klineData.Period + ":" + klineData.GetBar(pos));
             Console.WriteLine(klineData.Period + ":" + klineData.GetBar(pos));
         }
     }
 }
Esempio n. 3
0
 public static void PrintKLineData(IKLineData klineData)
 {
     for (int i = 0; i < klineData.Length; i++)
     {
         Console.WriteLine(klineData.GetBar(i));
     }
 }
Esempio n. 4
0
 private void RealTimeReader_OnBar(object sender, IKLineData klineData, int index)
 {
     if (index == 0)
     {
         return;
     }
     Console.WriteLine("kline:" + klineData.GetBar(index - 1));
 }
Esempio n. 5
0
 public void Loop(int barPos)
 {
     foreach (int period in periods)
     {
         MaData maData = dic_Period_MaData[period];
         maData.AddValue(barPos, klineData.GetBar(barPos), CalcMa(period, barPos));
     }
 }
Esempio n. 6
0
 public static void AssertEqual_KLineData(IKLineData klineData, IKLineData newklineData)
 {
     Assert.AreEqual(klineData.Length, newklineData.Length);
     for (int i = 0; i < klineData.Length; i++)
     {
         Assert.AreEqual(klineData.GetBar(i).ToString(), newklineData.GetBar(i).ToString());
     }
 }
Esempio n. 7
0
        private void Loop(int startBarPos, int endBarPos)
        {
            double start = klineData.GetBar(startBarPos).End;
            double high  = 0;
            double low   = double.MaxValue;

            for (int i = startBarPos; i <= endBarPos; i++)
            {
                IKLineBar bar = klineData.GetBar(i);
                if (bar.High > high)
                {
                    high = bar.High;
                }
                if (bar.Low < low)
                {
                    low = bar.Low;
                }
            }
        }
Esempio n. 8
0
 private static void PrintData(DataForForward_Code dataForForward, ForwardDataIndeier indeier, IKLineData_Extend klineData, int mainBarPos, KLinePeriod mainPeriod, List <string> list_OnBar)
 {
     Console.WriteLine(klineData.Period + ":" + klineData.GetBar(mainBarPos));
     list_OnBar.Add(klineData.Period + ":" + klineData.GetBar(mainBarPos));
     for (int m = 0; m < dataForForward.ReferedKLinePeriods.Count; m++)
     {
         KLinePeriod period = dataForForward.ReferedKLinePeriods[m];
         if (mainPeriod.Equals(period))
         {
             continue;
         }
         int barPos = indeier.GetOtherKLineBarPosIfFinished(mainBarPos, period);
         if (barPos >= 0)
         {
             IKLineData otherKLine = dataForForward.GetKLineData(period);
             Console.WriteLine(period + ":" + otherKLine.GetBar(barPos));
             list_OnBar.Add(period + ":" + otherKLine.GetBar(barPos));
         }
     }
     Console.WriteLine("分时线:" + dataForForward.CurrentTimeLineData.GetBar(mainBarPos));
     list_OnBar.Add("分时线:" + dataForForward.CurrentTimeLineData.GetBar(mainBarPos));
 }
Esempio n. 9
0
 private void Init_Day(IKLineData klineData, IList <ITradingTime> tradingTimes)
 {
     for (int i = 0; i < tradingTimes.Count; i++)
     {
         ITradingTime tradingTime = tradingTimes[i];
         int          tradingDay  = (int)klineData.GetBar(i).Time;
         KLineDataTradingTimeInfo_Day timeInfo = new KLineDataTradingTimeInfo_Day(tradingDay);
         timeInfo.StartPos = i;
         timeInfo.EndPos   = i;
         this.dic_TradingDay_KLineTimeInfo.Add(timeInfo.TradingDay, timeInfo);
         this.timeInfo_DayList.Add(timeInfo);
         tradingDays.Add(tradingTime.TradingDay);
     }
 }
Esempio n. 10
0
        private void btView_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                string fileName = openFileDialog1.FileName;
                if (fileName.ToLower().EndsWith("tick"))
                {
                    TickDataStore_File_Single store = new TickDataStore_File_Single(fileName);
                    TickData tickData = store.Load();
                    tbContent.Clear();

                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < tickData.Length; i++)
                    {
                        sb.AppendLine(tickData.GetBar(i).ToString());
                    }
                    tbContent.AppendText(sb.ToString());
                }
                else if (fileName.ToLower().EndsWith("kline"))
                {
                    KLineDataStore_File_Single store = new KLineDataStore_File_Single(fileName);
                    IKLineData tickData = store.LoadAll();
                    tbContent.Clear();

                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < tickData.Length; i++)
                    {
                        sb.AppendLine(tickData.GetBar(i).ToString());
                    }
                    tbContent.AppendText(sb.ToString());
                }
                else if (fileName.ToLower().EndsWith("csv"))
                {
                    tbContent.Text = File.ReadAllText(fileName);
                }
                else
                {
                    MessageBox.Show("不支持的格式");
                    return;
                }
                tbFileName.Text = fileName;
            }
        }
Esempio n. 11
0
 public IKLineBar GetBar(int index)
 {
     return(klineData.GetBar(index));
 }
Esempio n. 12
0
 public IKLineBar GetBar()
 {
     return(klineData.GetBar(barPos));
 }