Exemplo n.º 1
0
        public void TestSaveLoadUpdatedDataInfo()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "path_updateinfo");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            UpdatedDataInfo updatedDataInfo = new UpdatedDataInfo(path);

            updatedDataInfo.WriteUpdateInfo_Tick(CODE1, 20140120);
            updatedDataInfo.WriteUpdateInfo_Tick(CODE2, 20140520);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_1Minute, 20140121);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_5Minute, 20140122);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_15Minute, 20140123);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_1Day, 20140124);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE2, KLinePeriod.KLinePeriod_1Minute, 20140525);
            updatedDataInfo.Save();

            UpdatedDataInfo updatedDataInfo2 = new UpdatedDataInfo(path);

            Assert.AreEqual(20140120, updatedDataInfo2.GetLastUpdatedTickData(CODE1));
            Assert.AreEqual(20140520, updatedDataInfo2.GetLastUpdatedTickData(CODE2));

            Assert.AreEqual(20140121, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_1Minute));
            Assert.AreEqual(20140122, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_5Minute));
            Assert.AreEqual(20140123, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_15Minute));
            Assert.AreEqual(20140124, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_1Day));
            Assert.AreEqual(20140525, updatedDataInfo2.GetLastUpdatedKLineData(CODE2, KLinePeriod.KLinePeriod_1Minute));

            Directory.Delete(path, true);
        }
Exemplo n.º 2
0
        private void AddSteps_KLineData_Instrument(List <IStep> steps, CodeInfo codeInfo, CacheUtils_TradingDay tradingDaysCache)
        {
            //if (!(codeInfo.Exchange == "SQ" && codeInfo.Code.EndsWith("0000")))
            //    return;
            string code = codeInfo.Code;

            for (int i = 0; i < updatePeriods.Count; i++)
            {
                //TODO 暂时没处理FillUp的情况,考虑使用全覆盖的方式实现
                KLinePeriod period          = updatePeriods[i];
                int         lastUpdatedDate = updatedDataInfo.GetLastUpdatedKLineData(code, period);
                int         lastCodeDate    = codeInfo.End;
                if (lastCodeDate <= 0)
                {
                    lastCodeDate = tradingDaysCache.LastTradingDay;
                }

                //20171015 ww 在不全面更新数据情况下,如果最新的交易日比合约截止时间更新,则不再更新该合约数据
                int firstNewTradingDay = newTradingDays.Count == 0 ? tradingDaysCache.LastTradingDay : newTradingDays[0];
                if (firstNewTradingDay > lastCodeDate)
                {
                    continue;
                }

                if (!isFillUp)
                {
                    if (lastUpdatedDate >= lastCodeDate || lastUpdatedDate >= tradingDaysCache.LastTradingDay)
                    {
                        continue;
                    }
                }

                Step_UpdateKLineData step = new Step_UpdateKLineData(codeInfo, period, tradingDaysCache, historyData, klineDataStore, updatedDataInfo, updateInfoStore, isFillUp);
                steps.Add(step);
            }
        }