コード例 #1
0
        private static int GetEndIndex(CodeInfo codeInfo, CacheUtils_TradingDay allTradingDayCache)
        {
            int endIndex;

            if (codeInfo.End <= 0)
            {
                endIndex = allTradingDayCache.GetAllTradingDays().Count - 1;
            }
            else
            {
                endIndex = allTradingDayCache.GetTradingDayIndex(codeInfo.End, true);
            }
            return(endIndex);
        }
コード例 #2
0
        private List <int> GetAllNotUpdateTickData(CodeInfo codeInfo, CacheUtils_TradingDay allTradingDayCache, List <int> storedDays, bool isFillUp)
        {
            if (isFillUp)
            {
                HashSet <int> set = new HashSet <int>(storedDays);
                IList <int>   codeAllTradingDays   = GetCodeTradingDays(codeInfo, allTradingDayCache);
                List <int>    allNotUpdateTickData = new List <int>(set.Count);
                for (int i = 0; i < codeAllTradingDays.Count; i++)
                {
                    int day = codeAllTradingDays[i];
                    if (!set.Contains(day))
                    {
                        allNotUpdateTickData.Add(day);
                    }
                }
                return(allNotUpdateTickData);
            }
            else
            {
                /*
                 * 如果已更新数据记录中保存了该合约的最后更新日期,则直接按该信息更新后面的数据
                 * 否则扫描整个目录来获取待更新信息
                 */
                int lastUpdatedDate = updatedDataInfo.GetLastUpdatedTickData(codeInfo.Code);
                int startIndex;
                if (lastUpdatedDate >= 0)
                {
                    int lastSavedUpdateTickIndex = allTradingDayCache.GetTradingDayIndex(lastUpdatedDate);
                    startIndex = lastSavedUpdateTickIndex + 1;
                }
                else
                {
                    if (storedDays.Count == 0)
                    {
                        startIndex = allTradingDayCache.GetTradingDayIndex(codeInfo.Start, false);
                    }
                    else
                    {
                        storedDays.Sort();
                        int lastUpdateIndex = allTradingDayCache.GetTradingDayIndex(storedDays[storedDays.Count - 1]);
                        if (lastUpdateIndex < 0)
                        {
                            //TODO 不应该出现这种情况,TODO 写日志
                        }
                        startIndex = lastUpdateIndex + 1;
                    }

                    //保存更新信息
                    int lastUpdateTickIndex = startIndex - 1;
                    if (lastUpdateTickIndex >= 0 && lastUpdateTickIndex < allTradingDayCache.GetAllTradingDays().Count)
                    {
                        updatedDataInfo.WriteUpdateInfo_Tick(codeInfo.Code, allTradingDayCache.GetAllTradingDays()[lastUpdateTickIndex]);
                    }
                }
                if (startIndex < 0 || startIndex >= allTradingDayCache.GetAllTradingDays().Count)
                {
                    return(null);
                }

                int endIndex = GetEndIndex(codeInfo, allTradingDayCache);
                if (endIndex < startIndex)
                {
                    return(null);
                }

                int len = endIndex - startIndex + 1;
                if (len <= 0)
                {
                    return(null);
                }
                return(allTradingDayCache.GetAllTradingDays().GetRange(startIndex, len));
            }
        }