internal TradeSample(SecDBFileReader file, TradeSample ps, DateTime ts, Stream stream) : base(ts)
            {
                var flags = SecDBPrimitives.ReadByte(stream);

                InternalTrade = (flags & (1)) != 0;
                Aggressor     = (AggressorType)((flags >> 1) & 0x3);
                Side          = (SideType)((flags >> 3) & 0x1);

                IsQty     = (flags & (1 << 4)) != 0;
                IsTradeID = (flags & (1 << 5)) != 0;
                IsOrderID = (flags & (1 << 6)) != 0;

                var price = SecDBPrimitives.ReadSLEB128(stream);

                if (ps == null)
                {
                    PriceStep = price;
                }
                else
                {
                    PriceStep = ps.PriceStep + price;
                }

                Price = PriceStep * file.SystemHeader.PriceStep;

                if (IsQty)
                {
                    Qty = SecDBPrimitives.ReadSLEB128(stream);
                }
                if (IsTradeID)
                {
                    TradeID = SecDBPrimitives.ReadULEB128(stream);
                }
                if (IsOrderID)
                {
                    OrderID = SecDBPrimitives.ReadULEB128(stream);
                }
            }
        internal TradeSample(SecDBFileReader file, TradeSample ps, DateTime ts, Stream stream) : base(ts)
        {
           var flags = SecDBPrimitives.ReadByte(stream);

           InternalTrade =    (flags & (1)) !=0;
           Aggressor = (AggressorType)((flags >> 1)&0x3);
           Side = (SideType)((flags >> 3)&0x1);

           IsQty =      (flags & (1 << 4)) !=0;
           IsTradeID =  (flags & (1 << 5)) !=0;
           IsOrderID =  (flags & (1 << 6)) !=0;

           var price = SecDBPrimitives.ReadSLEB128(stream);
           if (ps==null)
              PriceStep = price;
            else
              PriceStep = ps.PriceStep + price;

           Price = PriceStep * file.SystemHeader.PriceStep;

           if (IsQty)      Qty  = SecDBPrimitives.ReadSLEB128(stream);
           if (IsTradeID)  TradeID = SecDBPrimitives.ReadULEB128(stream);
           if (IsOrderID)  OrderID = SecDBPrimitives.ReadULEB128(stream);
        }