예제 #1
0
        /// <summary>
        /// 调整规则:
        /// 1.如果该开始和结束
        ///
        /// 逻辑:
        /// 1.是否有repeat,如果没有repeat直接移动时间
        /// 2.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="period"></param>
        private void Adjust(TickData data, TickInfo_Period period)
        {
            TickPeriodAdjustInfo adjustInfo = period.adjustInfo;

            if (!adjustInfo.StartRepeat && !adjustInfo.EndRepeat)
            {
                Adjust_NoRepeat(data, period, adjustInfo);
                Console.WriteLine("NoRepeat");
            }
            else if (adjustInfo.StartRepeat && adjustInfo.EndRepeat)
            {
                Adjust_AllRepeat(data, period, adjustInfo);
                Console.WriteLine("AllRepeat");
            }
            //有时间偏移,首先根据偏移位置移正,再处理repeat
            else if (adjustInfo.HasTimeOffset())
            {
                Adjust_HasTimeOffsetAndRepeat(data, period, adjustInfo);
                Console.WriteLine("TimeOffset");
            }
            //起始位置repeat,末尾offset,且正好合拍
            else if (adjustInfo.HasRepeatOffset())
            {
                Adjust_HasRepeatOffset(data, period, adjustInfo);
            }
            //该数据段没有偏移,只有repeat
            else
            {
                Adjust_NoOffsetOnlyRepeat(data, period, adjustInfo);
            }
        }
예제 #2
0
        private void Adjust_NoRepeat(TickData data, TickInfo_Period period, TickPeriodAdjustInfo adjustInfo)
        {
            if (adjustInfo.HasTimeOffset())
            {
                AdjustTime(data, period.StartIndex, period.EndIndex, -adjustInfo.GetTimeOffset());
            }
            int adjustCount = AdjustPeriodStart(data, period);

            if (adjustCount > 2)
            {
                int startIndex = adjustInfo.IsOpen ? period.StartIndex + 1 : period.StartIndex;
                int endIndex   = startIndex + adjustCount - 1;
                SpreadRepeatForward(data, period, startIndex, endIndex);
            }

            adjustCount = AdjustPeriodEnd(data, period);
            if (adjustCount > 2)
            {
                int startIndex = period.EndIndex - adjustCount + 1;
                int endIndex   = period.EndIndex;
                SpreadRepeatBackward(data, period, startIndex, endIndex);
            }
        }