Exemplo n.º 1
0
 public void AddBar(double time, double open, double high, double low, double close, int volume, int openInterest)
 {
     timeStamp = TimeStamp.FromOADate(time);
     closeTick.Initialize();
     closeTick.SetTime(timeStamp);
     closeTick.SetTrade(close, volume);
     timeStamp.AddMilliseconds(-1);
     highTick.Initialize();
     highTick.SetTime(timeStamp);
     highTick.SetTrade(high, 0);
     timeStamp.AddMilliseconds(-1);
     lowTick.Initialize();
     lowTick.SetTime(timeStamp);
     lowTick.SetTrade(low, 0);
     timeStamp.AddMilliseconds(-1);
     openTick.Initialize();
     openTick.SetTime(timeStamp);
     openTick.SetTrade(open, 0);
     Add(openTick);
     Add(lowTick);
     Add(highTick);
     Add(closeTick);
 }
Exemplo n.º 2
0
        private bool TryReadTick(long length)
        {
            tickIO.SetSymbol(lSymbol);
            byte size = dataIn.ReadByte();

            // Check for old style prior to version 8 where
            // single byte version # was first.
            if (dataVersion < 8 && size < 8)
            {
                tickIO.FromReader((byte)size, dataIn);
            }
            else
            {
                // Subtract the size byte.
                if (dataIn.BaseStream.Position + size - 1 > length)
                {
                    return(false);
                }
                int count = 1;
                memory.SetLength(size);
                memory.GetBuffer()[0] = size;
                while (count < size)
                {
                    count += dataIn.Read(buffer, count, size - count);
                }
                memory.Position = 0;
                tickIO.FromReader(memory);
                if (dataVersion == 0)
                {
                    dataVersion = tickIO.DataVersion;
                }
            }
            var utcTime = new TimeStamp(tickIO.Extract().UtcTime);

            tickIO.SetTime(utcTime);
            return(true);
        }