internal SummarySample(DateTime ts, Stream stream) : base(ts)
            {
                var flags = SecDBPrimitives.ReadByte(stream);

                IsBidQty    = (flags & (1)) != 0;
                IsAskQty    = (flags & (1 << 1)) != 0;
                IsPositions = (flags & (1 << 2)) != 0;
                IsRisk      = (flags & (1 << 3)) != 0;

                if (IsBidQty)
                {
                    BidQty = SecDBPrimitives.ReadULEB128(stream);
                }
                if (IsAskQty)
                {
                    AskQty = SecDBPrimitives.ReadULEB128(stream);
                }
                if (IsPositions)
                {
                    Positions = SecDBPrimitives.ReadSLEB128(stream);
                }
                if (IsRisk)
                {
                    RiskAmt = SecDBPrimitives.ReadDouble(stream);
                }
            }
            internal QuoteSample(SecDBFileReader file, QuoteSample ps, DateTime ts, Stream stream) : base(ts)
            {
                var bt = SecDBPrimitives.ReadByte(stream);

                BidCount = bt & 0xf;
                AskCount = (bt & 0xf0) >> 4;
                var cnt = BidCount + AskCount;

                if (cnt == 0)
                {
                    throw new FinancialException(StringConsts.SECDB_FILE_HEADER_ERROR + "QuoteSample: no px levels");
                }

                PriceLevels = new PxLevel[cnt];

                var pxStep = file.SystemHeader.PriceStep;

                var currentPrice = 0L;

                for (var i = 0; i < cnt; i++)
                {
                    var price = SecDBPrimitives.ReadSLEB128(stream);
                    if (i == 0)
                    {
                        if (ps == null)
                        {
                            currentPrice = price;
                        }
                        else
                        {
                            currentPrice  = ps.PriceLevels[0].PriceStep;
                            currentPrice += price;
                        }
                    }
                    else
                    {
                        currentPrice += price;
                    }

                    var qty = SecDBPrimitives.ReadSLEB128(stream);

                    var pl = new PxLevel {
                        PriceStep = currentPrice, Price = currentPrice * pxStep, Quantity = qty
                    };
                    PriceLevels[i] = pl;
                }
            }
            internal OrderSample(SecDBFileReader file, OrderSample ps, DateTime ts, Stream stream) : base(ts)
            {
                var flags = SecDBPrimitives.ReadByte(stream);

                InternalOrder = (flags & (1)) != 0;
                CancelAll     = (flags >> 1) != 0;

                if (!CancelAll)
                {
                    IsActive      = (flags >> 2) != 0;
                    IsReplacement = (flags >> 3) != 0;
                    Side          = (SideType)((flags >> 4) & 0x1);

                    IsTakeProfit = (flags >> 5) != 0;
                    IsStopLoss   = (flags >> 6) != 0;

                    OrderID = SecDBPrimitives.ReadSLEB128(stream);

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

                        Price = PriceStep * file.SystemHeader.PriceStep;

                        Qty = SecDBPrimitives.ReadSLEB128(stream);
                    }

                    if (IsReplacement)
                    {
                        OldOrderID = SecDBPrimitives.ReadSLEB128(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);
                }
            }