Exemplo n.º 1
0
        private void AddSteps_TickData_Instrument(List <IStep> steps, string code, List <int> updateDays)
        {
            int stepCount           = updateDays.Count / DAYS_EVERYTICKSTEP;
            int lastStepUpdateCount = updateDays.Count % DAYS_EVERYTICKSTEP;

            if (lastStepUpdateCount != 0)
            {
                stepCount++;
            }
            else
            {
                lastStepUpdateCount = DAYS_EVERYTICKSTEP;
            }
            List <int>     openDates     = updateDays;
            ITickDataStore tickDataStore = dataStore.CreateTickDataStore();

            for (int i = 0; i < stepCount; i++)
            {
                IStep step;
                if (i != stepCount - 1)
                {
                    step = new Step_UpdateTickData(code, openDates.GetRange(i * DAYS_EVERYTICKSTEP, DAYS_EVERYTICKSTEP), historyData, tickDataStore);
                }
                else
                {
                    step = new Step_UpdateTickData(code, openDates.GetRange(i * DAYS_EVERYTICKSTEP, lastStepUpdateCount), historyData, tickDataStore, updatedDataInfo, updateInfoStore);
                }
                steps.Add(step);
            }
        }
Exemplo n.º 2
0
        public void TestTickDataStore_Append(string uri)
        {
            string         code          = "m1005";
            int            day           = 20100108;
            IDataStore     dataStore     = DataStoreFactory.CreateDataStore(uri);
            ITickDataStore tickDataStore = dataStore.CreateTickDataStore();

            try
            {
                TickData data = (TickData)MockDataLoader.GetTickData(code, day);

                TickData d1 = data.SubData(0, 100);
                TickData d2 = data.SubData(101, data.Length - 1);

                tickDataStore.Save(code, day, d1);
                tickDataStore.Append(code, day, d2);

                TickData data2 = tickDataStore.Load(code, day);

                AssertUtils.AssertEqual_TickData(data, data2);
            }
            finally
            {
                tickDataStore.Delete(code, day);
            }
        }
Exemplo n.º 3
0
 public Step_UpdateTickData(string code, List <int> tradingDays, IPlugin_HistoryData historyData, ITickDataStore tickDataStore)
 {
     this.code          = code;
     this.tradingDays   = tradingDays;
     this.historyData   = historyData;
     this.tickDataStore = tickDataStore;
 }
Exemplo n.º 4
0
        private void AddSteps_TickData_TradingDay(List <IStep> steps, IList <CodeInfo> codes, int tradingDay)
        {
            ITickDataStore tickDataStore = dataStore.CreateTickDataStore();

            for (int i = 0; i < codes.Count; i++)
            {
                CodeInfo codeInfo = codes[i];
                if (codeInfo.End == 0 || codeInfo.End >= tradingDay)
                {
                    List <int> tradingDays = new List <int>();
                    tradingDays.Add(tradingDay);
                    Step_UpdateTickData step = new Step_UpdateTickData(codeInfo.Code, tradingDays, historyData, tickDataStore, true);
                    steps.Add(step);
                }
            }
        }
Exemplo n.º 5
0
        private void AddSteps_TickData(List <IStep> steps)
        {
            ITickDataStore tickDataStore = dataStore.CreateTickDataStore();

            List <CodeInfo> allInstruments = historyData.GetInstruments();
            List <int>      allTradingDays = historyData.GetTradingDays();

            CacheUtils_TradingDay tradingDayCache = new CacheUtils_TradingDay(allTradingDays);

            for (int i = 0; i < allInstruments.Count; i++)
            //for (int i = 0; i < 10; i++)
            {
                CodeInfo instrument = allInstruments[i];

                //if (!(instrument.Exchange == "SQ" && instrument.Code.EndsWith("0000")))
                //    continue;

                int lastTradingDay = instrument.End;
                if (lastTradingDay <= 0)
                {
                    lastTradingDay = tradingDayCache.LastTradingDay;
                }
                int lastUpdatedDate = updatedDataInfo.GetLastUpdatedTickData(instrument.Code);
                if (lastUpdatedDate < instrument.Start)
                {
                    lastUpdatedDate = tradingDayCache.GetPrevTradingDay(instrument.Start);
                }

                List <int> allDays;
                if (!isFillUp)
                {
                    if (lastUpdatedDate >= lastTradingDay)
                    {
                        continue;
                    }
                    int startDate = tradingDayCache.GetNextTradingDay(lastUpdatedDate);
                    //如果不填充数据,直接根据最新交易日期和最后更新日期
                    int endDate = instrument.End;
                    if (endDate <= 0)
                    {
                        endDate = allTradingDays[allTradingDays.Count - 1];
                    }

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

                    IList <int> tradingDays = tradingDayCache.GetTradingDays(lastUpdatedDate, endDate);
                    if (tradingDays == null || tradingDays.Count == 0)
                    {
                        continue;
                    }
                    allDays = new List <int>();
                    allDays.AddRange(tradingDays);
                    //allTradingDays
                }
                else
                {
                    //如果填充所有数据
                    List <int> storedAllDays = tickDataStore.GetAllDays(instrument.Code);
                    allDays = GetAllNotUpdateTickData(instrument, tradingDayCache, storedAllDays, isFillUp);
                    if (allDays == null)
                    {
                        continue;
                    }
                }

                AddSteps_TickData_Instrument(steps, instrument.Code, allDays);
            }
        }
Exemplo n.º 6
0
 public TickDataReader(IDataStore dataStore, IDataReader dataReader)
 {
     this.tickDataStore = dataStore.CreateTickDataStore();
     this.dataReader    = dataReader;
 }
Exemplo n.º 7
0
 public Step_UpdateTickData(string code, List <int> tradingDays, IPlugin_HistoryData historyData, ITickDataStore tickDataStore, UpdatedDataInfo updatedDataInfo, IUpdateInfoStore updateInfoStore) : this(code, tradingDays, historyData, tickDataStore)
 {
     this.updatedDataInfo = updatedDataInfo;
     this.updateInfoStore = updateInfoStore;
 }