コード例 #1
0
        private static PriceSeries GetPriceBarsFromPath(string path)
        {
            var priceSeries = new PriceSeries();

            var assembly = typeof(DataManager).GetTypeInfo().Assembly;
            var stream   = assembly.GetManifestResourceStream(path);

            using (var reader = new StreamReader(stream))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    var priceBar = new PriceBar();
                    // Line Format:
                    // Date, Open, High, Low, Close, Volume
                    // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12
                    var tokens = line.Split(',');
                    priceBar.DateTime = DateTime.Parse(tokens[0], DateTimeFormatInfo.InvariantInfo);
                    priceBar.Open     = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo);
                    priceBar.High     = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo);
                    priceBar.Low      = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo);
                    priceBar.Close    = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo);
                    priceBar.Volume   = long.Parse(tokens[5], NumberFormatInfo.InvariantInfo);
                    priceSeries.Add(priceBar);
                }
            }
            return(priceSeries);
        }
コード例 #2
0
        public PriceSeries Clip(int startIndex, int endIndex)
        {
            var result = new PriceSeries(endIndex - startIndex);

            for (var i = startIndex; i < endIndex; i++)
            {
                result.Add(this[i]);
            }
            return(result);
        }