コード例 #1
0
        public IStockKLine GetData(string stockCode, KLineType kLineType, DateTime dt)
        {
            string filepath = PathHelper.GetKLineDataFilePath(stockCode, kLineType, dt);

            if (File.Exists(filepath))
            {
                var file = new StockKLineFile(filepath);
                var lstAll = file.ReadAll();
                var lstQuery = lstAll.Where(x => x.Time == dt).ToList();
                if (lstQuery != null && lstQuery.Count > 0)
                    return lstQuery.First();
            }

            return null;
        }
コード例 #2
0
        public IEnumerable<IStockKLine> GetData(string stockCode, KLineType kLineType, DateTime bgnDt, DateTime endDt)
        {
            List<string> pathList = PathHelper.GetKLineDataFilePath(stockCode, kLineType, bgnDt, endDt).ToList();

            List<StockKLineDataItem> result = new List<StockKLineDataItem>();
            foreach (string path in pathList)
            {
                if (File.Exists(path))
                {
                    var file = new StockKLineFile(path);
                    var lstAll = file.ReadAll();
                    var lstQuery = lstAll.Where(x => x.Time >= bgnDt && x.Time <= endDt);
                    result.AddRange(lstQuery);
                }
            }

            return result.Cast<IStockKLine>();
        }
コード例 #3
0
        public IEnumerable<IStockKLine> GetLatest(IEnumerable<string> stockCodes, KLineType kLineType)
        {
            List<IStockKLine> result = new List<IStockKLine>();
            foreach (string code in stockCodes)
            {
                string filePath = string.Empty;
                if (PathHelper.GetLatestKLineDataFilePath(code, kLineType, ref filePath))
                {
                    var file = new StockKLineFile(filePath);
                    var lstAll = from it in file.ReadAll()
                                 orderby it.Time descending
                                 select it;
                    IStockKLine fst = lstAll.First();
                    if (fst != null)
                        result.Add(fst);
                }
            }

            return result.Cast<IStockKLine>();
        }