Esempio n. 1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            ITickData_Extend currentTickData = forwardData.CurrentTickData;
            bool             canForward      = true;

            if (currentTickData == null)
            {
                this.Pause();
                return;
            }
            int barPos     = currentTickData.BarPos;
            int nextBarPos = barPos + 1;

            if (nextBarPos >= currentTickData.Length)
            {
                canForward = this.Forward();
            }
            else
            {
                mileSecondCount++;
                if (mileSecondCount == 4)
                {
                    forwardTime     = TimeUtils.AddSeconds(forwardTime, 1);
                    mileSecondCount = 0;
                }
                if (forwardTime >= currentTickData.Arr_Time[nextBarPos])
                {
                    canForward = this.Forward();
                }
            }
            if (!canForward)
            {
                this.Pause();
            }
        }
Esempio n. 2
0
 private void AdjustTime(TickData data, int startIndex, int endIndex, int offSecond)
 {
     for (int i = startIndex; i <= endIndex; i++)
     {
         data.arr_time[i] = TimeUtils.AddSeconds(data.arr_time[i], offSecond);
     }
 }
Esempio n. 3
0
        private void SpreadRepeatBackward(TickData data, TickInfo_Period period, int repeatStartIndex, int repeatEndIndex)
        {
            /**
             *
             * 145956
             * 145957
             * 145958
             * 145958
             * 150000
             * 150000
             * 150000
             * 150000
             * 150000
             *
             * 该算法是处理向前扩散,比如上面例子,在一个时间上有太多的tick数据
             * 明显不正常,所以
             */
            //int timesEverySecond = 2;
            double timeRepeat  = data.arr_time[repeatEndIndex];
            int    repeatTimes = repeatEndIndex - repeatStartIndex + 1;
            int    startIndex  = -1;
            int    capcity     = 0;

            for (int i = repeatStartIndex - 1; i >= 0; i--)
            {
                int      currentDataCount = repeatStartIndex - i - 1 + repeatTimes;
                TimeSpan span             = TimeUtils.Substract(timeRepeat, data.arr_time[i]);
                int      currentCapcity   = timesEverySecond * (span.Minutes * 60 + span.Seconds);
                if (currentCapcity >= currentDataCount)
                {
                    startIndex = i + 1;
                    capcity    = currentCapcity;
                    break;
                }
            }

            int    allIndex = repeatEndIndex - startIndex + 1;
            double rate     = (double)capcity / allIndex / 2;

            double startTime = Math.Round((double)data.TradingDay + period.StartTime, 6);
            double rptTime   = data.arr_time[repeatStartIndex];

            for (int i = repeatEndIndex - 2; i >= startIndex; i--)
            {
                double time = TimeUtils.AddSeconds(rptTime, -(int)(((double)(repeatEndIndex - i)) * rate));
                data.arr_time[i] = time > startTime ? time : startTime;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 向前展开起始位置的重复数据
        /// </summary>
        /// <param name="data"></param>
        /// <param name="repeatStartIndex"></param>
        /// <param name="repeatEndIndex"></param>
        /// <param name="isPrev"></param>
        private void SpreadRepeatForward(TickData data, TickInfo_Period period, int repeatStartIndex, int repeatEndIndex)
        {
            /**
             * 找到调整结束位置
             * 算法:
             * 1.从起始位置开始查找
             * 2.一直找到(结束时间-开始时间)*2>重复的时间数+
             *
             * 090000
             * 090000
             * 090000
             * 090000
             * 090000
             * 090002
             * 090003
             * 090003
             */
            //int timesEverySecond = 2;
            double timeRepeat  = data.arr_time[repeatStartIndex];
            int    repeatTimes = repeatEndIndex - repeatStartIndex + 1;
            int    endIndex    = -1;
            int    capcity     = 0;

            for (int i = repeatEndIndex + 1; i < data.Length; i++)
            {
                int      currentDataCount = i - repeatEndIndex - 1 + repeatTimes;
                TimeSpan span             = TimeUtils.Substract(data.arr_time[i], timeRepeat);
                int      currentCapcity   = timesEverySecond * (span.Minutes * 60 + span.Seconds);
                if (currentCapcity >= currentDataCount)
                {
                    endIndex = i - 1;
                    capcity  = currentCapcity;
                    break;
                }
            }

            int    allIndex = endIndex - repeatStartIndex + 1;
            double rate     = (double)capcity / allIndex / 2;

            double endTime = Math.Round((double)data.TradingDay + period.EndTime, 6);
            double rptTime = data.arr_time[repeatStartIndex];

            for (int i = repeatStartIndex + 2; i <= endIndex; i++)
            {
                double time = TimeUtils.AddSeconds(rptTime, (int)(((double)(i - repeatStartIndex)) * rate));
                data.arr_time[i] = time < endTime ? time : endTime;
            }
        }