Esempio n. 1
0
            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;
                }
            }
Esempio n. 2
0
        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;
          }
        }