Example #1
0
        public DataNavigate_Code2(IDataReader dataReader, string code, double time)
        {
            int openDate = dataReader.CreateTradingTimeReader(code).GetRecentTradingDay(time);
            ITradingDayReader tradingDayReader = dataReader.TradingDayReader;

            int index = dataReader.TradingDayReader.GetTradingDayIndex(openDate);
            //默认取前100天,后50天数据
            int startIndex = index - 100;

            startIndex = startIndex < 0 ? 0 : startIndex;
            int startDate = tradingDayReader.GetTradingDay(startIndex);

            int endIndex = index + 50;

            if (endIndex >= tradingDayReader.GetAllTradingDays().Count)
            {
                endIndex = tradingDayReader.GetAllTradingDays().Count - 1;
            }
            int endDate = tradingDayReader.GetTradingDay(endIndex);

            this.dataPackage = DataPackageFactory.CreateDataPackage(dataReader, code, startDate, endDate);
            this.NavigateTo(time);
        }
Example #2
0
        internal static IDataPackage_Code CreateDataPackage(IDataReader dataReader, string code, int openDate, int beforeDays, int afterDays, int minKlineBefore, int minKlineAfter)
        {
            ITradingTimeReader_Code tradingTimeReader = dataReader.CreateTradingTimeReader(code);
            ITradingDayReader       tradingDayReader  = dataReader.TradingDayReader;

            int index      = dataReader.TradingDayReader.GetTradingDayIndex(openDate);
            int startIndex = index - beforeDays;

            startIndex = startIndex < 0 ? 0 : startIndex;
            int startDate = tradingDayReader.GetTradingDay(startIndex);

            startDate = tradingTimeReader.GetRecentTradingDay(startDate, true);

            int endIndex = index + afterDays;

            if (endIndex >= tradingDayReader.GetAllTradingDays().Count)
            {
                endIndex = tradingDayReader.GetAllTradingDays().Count - 1;
            }
            int endDate = tradingDayReader.GetTradingDay(endIndex);

            //endDate = tradingTimeReader.GetRecentTradingDay(endDate, false);
            return(CreateDataPackage(dataReader, code, startDate, endDate, minKlineBefore, minKlineAfter));
        }