示例#1
0
        public void TestGetPeriod()
        {
            KLineData   data   = GetKLineData_1Min();
            KLinePeriod period = data.Period;

            Assert.AreEqual(KLinePeriod.KLinePeriod_1Minute, period);
        }
示例#2
0
        public void TestIndexOfTime()
        {
            KLineData data = GetKLineData_1Min();

            Assert.AreEqual(42, data.IndexOfTime(20131202.094255));
            Assert.AreEqual(43, data.IndexOfTime(20131202.0943));
            Assert.AreEqual(43, data.IndexOfTime(20131202.094305));
        }
示例#3
0
 public void Copy2KLineData(KLineData klineData, int currentKLineIndex)
 {
     klineData.arr_time[currentKLineIndex]  = this.Time;
     klineData.arr_start[currentKLineIndex] = this.Start;
     klineData.arr_high[currentKLineIndex]  = this.High;
     klineData.arr_low[currentKLineIndex]   = this.Low;
     klineData.arr_end[currentKLineIndex]   = this.End;
     klineData.arr_mount[currentKLineIndex] = this.Mount;
     klineData.arr_money[currentKLineIndex] = this.Money;
     klineData.arr_hold[currentKLineIndex]  = this.Hold;
 }
示例#4
0
        public void TestKLineData_GetRange()
        {
            KLineData  data     = GetKLineData_1Min();
            IKLineData data_sub = data.GetRange(100, 200);

            for (int i = 100; i <= 200; i++)
            {
                data.BarPos     = i;
                data_sub.BarPos = i - 100;
                Assert.AreEqual(data.ToString(), data_sub.ToString());
            }
        }
示例#5
0
        public void TestKLineData_Sub()
        {
            KLineData  data     = GetKLineData_1Min();
            IKLineData data_sub = data.Sub(100, 200);

            for (int i = 100; i <= 200; i++)
            {
                data.BarPos     = i;
                data_sub.BarPos = i - 100;
                Assert.AreEqual(data.ToString(), data_sub.ToString());
            }
            Assert.AreEqual(101, data_sub.Length);
        }
示例#6
0
 private static void Copy(KLineData targetData, int targetIndex, IKLineData srcData, int srcIndex, int length)
 {
     for (int i = srcIndex; i < srcIndex + length; i++)
     {
         int currentTargetIndex = targetIndex + srcIndex + i;
         targetData.arr_time[currentTargetIndex]  = srcData.Arr_Time[i];
         targetData.arr_start[currentTargetIndex] = srcData.Arr_Start[i];
         targetData.arr_high[currentTargetIndex]  = srcData.Arr_High[i];
         targetData.arr_low[currentTargetIndex]   = srcData.Arr_Low[i];
         targetData.arr_end[currentTargetIndex]   = srcData.Arr_End[i];
         targetData.arr_mount[currentTargetIndex] = srcData.Arr_Mount[i];
         targetData.arr_money[currentTargetIndex] = srcData.Arr_Money[i];
         targetData.arr_hold[currentTargetIndex]  = srcData.Arr_Hold[i];
     }
 }
示例#7
0
        public virtual IKLineData GetRange(int start, int end)
        {
            IKLineData data = this;
            KLineData  d1   = new KLineData(end - start + 1);

            for (int i = start; i <= end; i++)
            {
                d1.arr_time[i - start]  = data.Arr_Time[i];
                d1.arr_start[i - start] = data.Arr_Start[i];
                d1.arr_high[i - start]  = data.Arr_High[i];
                d1.arr_low[i - start]   = data.Arr_Low[i];
                d1.arr_end[i - start]   = data.Arr_End[i];
                d1.arr_mount[i - start] = data.Arr_Mount[i];
                d1.arr_money[i - start] = data.Arr_Money[i];
                d1.arr_hold[i - start]  = data.Arr_Hold[i];
            }
            return(d1);
        }
示例#8
0
        public static IKLineData Merge(IList <IKLineData> dataList)
        {
            int len = 0;

            for (int i = 0; i < dataList.Count; i++)
            {
                len += dataList[i].Length;
            }
            KLineData data   = new KLineData(len);
            int       offset = 0;

            for (int i = 0; i < dataList.Count; i++)
            {
                IKLineData d1 = dataList[i];
                Copy(data, offset, d1, 0, d1.Length);
                offset += d1.Length;
            }

            return(data);
        }
示例#9
0
        public void TestKLineMerge()
        {
            KLineData  data = GetKLineData_1Min();
            IKLineData d1   = data.GetRange(0, 99);
            IKLineData d2   = data.GetRange(100, 199);
            IKLineData d3   = data.GetRange(200, 299);
            IKLineData d4   = data.GetRange(300, data.Length - 1);

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

            dataList.Add(d1);
            dataList.Add(d2);
            dataList.Add(d3);
            dataList.Add(d4);
            IKLineData dataResult = KLineData.Merge(dataList);

            Assert.AreEqual(dataResult.Length, data.Length);
            for (int i = 0; i < data.Length; i++)
            {
                data.BarPos       = i;
                dataResult.BarPos = i;
                Assert.AreEqual(dataResult.ToString(), data.ToString());
            }
        }
示例#10
0
 public void TestKLineData_Sub_Exception()
 {
     KLineData  data     = GetKLineData_1Min();
     IKLineData data_sub = data.Sub(100, 200);
     float      start    = data_sub.Arr_Start[102];
 }