Пример #1
0
        public override void GetNextTick(ref GMarketDataType data)
        {
            string retString = GetNextLinePivotFormatted();

            if (retString != null)
            {
                string[] split = retString.Split('\t');

                data.time     = DateTime.ParseExact(split[0], dateFormats, CultureInfo.InvariantCulture, DateTimeStyles.None).ToLocalTime();
                data.tickType = (GTickTypeEnum)Enum.Parse(typeof(GTickTypeEnum), split[1]);

                try
                {
                    data.price = Double.Parse(split[2], curCulture);
                }
                catch (FormatException)
                {
                    SwapCulture();
                    data.price = Double.Parse(split[2], curCulture);
                }

                data.volume = Int32.Parse(split[3]);
            }
            else
            {
                data.time = GUtils.nullDT;

                if (ManageFileChange())
                {
                    GetNextTick(ref data);
                }
            }
        }
Пример #2
0
        public void SetCursorTime(DateTime time0, ref GMarketDataType data)
        {
            long time0tick = time0.Ticks;
            long ticktime;

            data.time = GUtils.nullDT;

            if (_FindFileNameAndOpen(time0.ToUniversalTime().Date))
            {
                do
                {
                    GetNextTick(ref data);
                    ticktime = data.time.Ticks;
                }while ((ticktime != 0L) && (ticktime < time0tick));
            }
        }
Пример #3
0
        public override void GetNextTick(ref GMarketDataType data)
        {
            byte statbyte;

            data.isNewTimeStamp = GMarketDataType.GTimeStampStatus.Different;

            try
            {
                statbyte = br.ReadByte();
            }
            catch (EndOfStreamException)
            {
                data.time = GUtils.nullDT;

                if (ManageFileChange())
                {
                    GetNextTick(ref data);
                }

                return;
            }

            if (statbyte >> 6 == 1)
            {
                _lastReadMinute = DateTime.ParseExact(br.ReadUInt32().ToString("D10") + "00", dateFormat, CultureInfo.InvariantCulture).ToLocalTime();
                _lastReadPivot  = br.ReadUInt32() * tickSize;
                GetNextTick(ref data);
                return;
            }

            else
            {
                if (statbyte >> 6 == 3)
                {
                    _lastReadSecond = _lastReadMinute.AddSeconds(br.ReadByte());
                }
                else
                {
                    data.isNewTimeStamp = GMarketDataType.GTimeStampStatus.Same;
                }


                data.tickType = (GTickTypeEnum)((statbyte & 56 /*00111000*/) >> 3);
                data.time     = _lastReadSecond;

                if ((statbyte & 7 /*00000111*/) == 7)
                {
                    SByte toto = br.ReadSByte();

                    data.volume = toto & 15 /*00001111*/;
                    data.price  = _lastReadPivot + ((SByte)(toto & 240 /*11110000*/) >> 4) * tickSize;
                }
                else
                {
                    if ((statbyte & 4 /*00000100*/) > 0)
                    {
                        data.price = _lastReadPivot + br.ReadInt16() * tickSize;
                    }
                    else
                    {
                        data.price = _lastReadPivot + br.ReadSByte() * tickSize;
                    }

                    if ((statbyte & 3 /*00000011*/) == 0)
                    {
                        data.volume = br.ReadByte();
                    }
                    else if ((statbyte & 3 /*00000011*/) == 1)
                    {
                        data.volume = br.ReadUInt16();
                    }
                    else if ((statbyte & 3 /*00000011*/) == 2)
                    {
                        data.volume = br.ReadInt32();
                    }
                }
            }
        }
Пример #4
0
 public abstract void GetNextTick(ref GMarketDataType data);