示例#1
0
        /// <summary>
        /// 既有偏移又有repeat的情况
        /// </summary>
        /// <param name="data"></param>
        /// <param name="period"></param>
        /// <param name="adjustInfo"></param>
        private void Adjust_HasTimeOffsetAndRepeat(TickData data, TickInfo_Period period, TickPeriodAdjustInfo adjustInfo)
        {
            AdjustTime(data, period.StartIndex, period.EndIndex, -adjustInfo.GetTimeOffset());
            AdjustPeriodStart(data, period);
            if (adjustInfo.StartRepeat)
            {
                int startIndex = adjustInfo.StartRepeatIndex;
                int endIndex   = adjustInfo.StartRepeatIndex + adjustInfo.StartRepeatTimes - 1;
                //如果调整后向前移动的空间能够容纳下repeat,则向前填充
                if (-adjustInfo.GetTimeOffset() * 2 > adjustInfo.StartRepeatTimes)
                {
                    SpreadRepeatBackward(data, period, startIndex, endIndex);
                }
                else
                {
                    int mIndex = startIndex - adjustInfo.GetTimeOffset() * 2 - 4;
                    SpreadRepeatBackward(data, period, startIndex, mIndex);
                    SpreadRepeatForward(data, period, mIndex, endIndex);
                }
            }

            AdjustPeriodEnd(data, period);
            if (adjustInfo.EndRepeat)
            {
                int startIndex = adjustInfo.EndRepeatIndex;
                int endIndex   = adjustInfo.EndRepeatIndex + adjustInfo.EndRepeatTimes - 1;
                //如果调整后向前移动的空间能够容纳下repeat,则向前填充
                if (adjustInfo.GetTimeOffset() * 2 > adjustInfo.EndRepeatTimes)
                {
                    SpreadRepeatForward(data, period, startIndex, endIndex);
                }
                else
                {
                    int mIndex = endIndex - adjustInfo.GetTimeOffset() * 2 + 4;
                    SpreadRepeatBackward(data, period, startIndex, mIndex);
                    SpreadRepeatForward(data, period, mIndex, endIndex);
                }
            }
        }
示例#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);
            }
        }