Example #1
0
        public override object Read(BinaryReader reader, byte version)
        {
            int id          = reader.ReadInt32();
            var type        = (InstrumentType)reader.ReadByte();
            var symbol      = reader.ReadString();
            var description = reader.ReadString();
            var currencyId  = reader.ReadByte();
            var exchange    = reader.ReadString();
            var instrument  = new Instrument(id, type, symbol, description, currencyId, exchange);

            instrument.TickSize = reader.ReadDouble();
            instrument.Maturity = new DateTime(reader.ReadInt64());
            instrument.Factor   = reader.ReadDouble();
            instrument.Strike   = reader.ReadDouble();
            instrument.PutCall  = (PutCall)reader.ReadByte();
            instrument.Margin   = reader.ReadDouble();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                instrument.AltId.Add((AltId)this.streamerManager.Deserialize(reader));
            }

            count = reader.ReadInt32();
            for (int j = 0; j < count; j++)
            {
                instrument.Legs.Add((Leg)this.streamerManager.Deserialize(reader));
            }

            if (version == 0)
            {
                int cnt = reader.ReadInt32();
                for (int k = 0; k < cnt; k++)
                {
                    instrument.Fields[k] = reader.ReadDouble();
                }
            }

            if (version >= 1)
            {
                instrument.PriceFormat = reader.ReadString();
            }

            if (version >= 1 && version <= 4)
            {
                int size = reader.ReadInt32();
                if (size != -1)
                {
                    byte typeId = reader.ReadByte();
                    byte ver    = reader.ReadByte();
                    var  fields = new ObjectTable();
                    int  index;
                    while ((index = reader.ReadInt32()) != -1)
                    {
                        typeId = reader.ReadByte();
                        var objectStreamer = this.streamerManager.Get(typeId);
                        fields[index] = objectStreamer.Read(reader, ver);
                    }
                    instrument.Fields = fields;
                }
            }
            if (version >= 2)
            {
                instrument.CCY1 = reader.ReadByte();
                instrument.CCY2 = reader.ReadByte();
            }

            if (version >= 3)
            {
                instrument.DeleteCached = reader.ReadBoolean();
            }

            if (version >= 4)
            {
                instrument.Formula = reader.ReadString();
            }

            if (version >= 5)
            {
                int eof = reader.ReadInt32();
                if (eof != -1)
                {
                    instrument.Fields = (ObjectTable)this.streamerManager.Deserialize(reader);
                }
            }
            return(instrument);
        }