Ejemplo n.º 1
0
        private void ReadBarsAgo(BinaryReader reader, BarSeries barlist, DateTime now, int len)
        {
            int i = 0;

            for (; i < _icount; ++i)
            {
                #region

                int year  = reader.ReadInt16();
                int month = reader.ReadByte();
                int day   = reader.ReadByte();

                DateTime dt = new DateTime(year, month, day);

                if (dt > now)
                {
                    break;
                }

                Bar bar = new Bar();

                bar.BeginTime    = dt;
                bar.EndTime      = dt;
                bar.Open         = reader.ReadInt32() / 1000.0;
                bar.Close        = reader.ReadInt32() / 1000.0;
                bar.High         = reader.ReadInt32() / 1000.0;
                bar.Low          = reader.ReadInt32() / 1000.0;
                bar.PreClose     = reader.ReadInt32() / 1000.0;
                bar.Volume       = reader.ReadDouble();
                bar.Turnover     = reader.ReadDouble();
                bar.OpenInterest = reader.ReadDouble();
                bar.IsCompleted  = true;
                bar.TradingDate  = dt;
                barlist.Add(bar);

                #endregion
            }

            if (i > len)
            {
                int rmlen = i - len;
                barlist.RemoveRange(barlist.Count - i, rmlen);
            }
        }