Exemplo n.º 1
0
        // **********************************************************************

        public void Write(DateTime dateTime, OwnTradeReply reply)
        {
            dw.WriteRecHeader(sid, dateTime);

            dw.WriteGrowing(DateTimeHelper.ToMs(reply.DateTime), ref lastMilliseconds);

            dw.WriteLeb128(reply.TradeId - lastTradeId);
            lastTradeId = reply.TradeId;

            dw.WriteLeb128(reply.OrderId - lastOrderId);
            lastOrderId = reply.OrderId;

            dw.WriteLeb128(reply.Price - lastPrice);
            lastPrice = reply.Price;

            dw.WriteLeb128(reply.Quantity);
        }
Exemplo n.º 2
0
        // **********************************************************************

        public void Write(DateTime dateTime, Deal deal)
        {
            dw.WriteRecHeader(sid, dateTime);

            // ------------------------------------------------------------

            long      milliseconds = DateTimeHelper.ToMs(deal.DateTime);
            DealFlags flags        = (DealFlags)deal.Type & DealFlags.Type;

            if (lastMilliseconds != milliseconds)
            {
                flags |= DealFlags.DateTime;
            }

            if (deal.Id != 0)
            {
                flags |= DealFlags.Id;
            }

            //if(deal.OrderId != 0)
            //  flags |= DealFlags.OrderId;

            if (lastRawPrice != deal.Price)
            {
                lastRawPrice = deal.Price;
                flags       |= DealFlags.Price;
            }

            if (lastVolume != deal.Volume)
            {
                flags |= DealFlags.Volume;
            }

            if (lastOI != deal.OI)
            {
                flags |= DealFlags.OI;
            }

            // ------------------------------------------------------------

            dw.Write((byte)flags);

            // ------------------------------------------------------------

            if ((flags & DealFlags.DateTime) != 0)
            {
                dw.WriteGrowing(milliseconds, ref lastMilliseconds);
            }

            if ((flags & DealFlags.Id) != 0)
            {
                dw.WriteGrowing(deal.Id, ref lastId);
            }

            if ((flags & DealFlags.Price) != 0)
            {
                int p = s.GetTicks(deal.Price);

                dw.WriteLeb128(p - lastPrice);
                lastPrice = p;
            }

            if ((flags & DealFlags.Volume) != 0)
            {
                dw.WriteLeb128(deal.Volume);
                lastVolume = deal.Volume;
            }

            if ((flags & DealFlags.OI) != 0)
            {
                dw.WriteLeb128(deal.OI - lastOI);
                lastOI = deal.OI;
            }

            // ------------------------------------------------------------
        }
Exemplo n.º 3
0
        // **********************************************************************

        public void Write(DateTime dateTime, OrdLogEntry entry)
        {
            dw.WriteRecHeader(sid, dateTime);

            // ------------------------------------------------------------

            long             milliseconds = DateTimeHelper.ToMs(entry.DateTime);
            OrdLogEntryFlags flags        = OrdLogEntryFlags.None;

            // ------------------------------------------------------------

            if (lastMilliseconds != milliseconds)
            {
                flags |= OrdLogEntryFlags.DateTime;
            }

            if (lastOrderId != entry.OrderId)
            {
                flags |= OrdLogEntryFlags.OrderId;
            }

            if (lastPrice != entry.Price)
            {
                flags |= OrdLogEntryFlags.Price;
            }

            if (lastAmount != entry.Amount)
            {
                flags |= OrdLogEntryFlags.Amount;
            }

            if ((entry.Flags & OrdLogFlags.Fill) != 0)
            {
                if (lastAmountRest != entry.AmountRest)
                {
                    flags |= OrdLogEntryFlags.AmountRest;
                }

                if (lastDealId != entry.DealId)
                {
                    flags |= OrdLogEntryFlags.DealId;
                }

                if (lastDealPrice != entry.DealPrice)
                {
                    flags |= OrdLogEntryFlags.DealPrice;
                }

                if (lastOI != entry.OI)
                {
                    flags |= OrdLogEntryFlags.OI;
                }
            }

            // ------------------------------------------------------------

            dw.Write((byte)flags);

            // ------------------------------------------------------------

            dw.Write((ushort)entry.Flags);

            if ((flags & OrdLogEntryFlags.DateTime) != 0)
            {
                dw.WriteGrowing(milliseconds, ref lastMilliseconds);
            }

            if ((flags & OrdLogEntryFlags.OrderId) != 0)
            {
                if ((entry.Flags & OrdLogFlags.Add) != 0)
                {
                    dw.WriteGrowing(entry.OrderId, ref lastOrderId);
                }
                else
                {
                    dw.WriteLeb128(entry.OrderId - lastOrderId);
                }
            }

            if ((flags & OrdLogEntryFlags.Price) != 0)
            {
                dw.WriteLeb128(entry.Price - lastPrice);
                lastPrice = entry.Price;
            }

            if ((flags & OrdLogEntryFlags.Amount) != 0)
            {
                dw.WriteLeb128(entry.Amount);
                lastAmount = entry.Amount;
            }

            if ((flags & OrdLogEntryFlags.AmountRest) != 0)
            {
                dw.WriteLeb128(entry.AmountRest);
                lastAmountRest = entry.AmountRest;
            }

            if ((flags & OrdLogEntryFlags.DealId) != 0)
            {
                dw.WriteGrowing(entry.DealId, ref lastDealId);
            }

            if ((flags & OrdLogEntryFlags.DealPrice) != 0)
            {
                dw.WriteLeb128(entry.DealPrice - lastDealPrice);
                lastDealPrice = entry.DealPrice;
            }

            if ((flags & OrdLogEntryFlags.OI) != 0)
            {
                dw.WriteLeb128(entry.OI - lastOI);
                lastOI = entry.OI;
            }

            // ------------------------------------------------------------
        }
Exemplo n.º 4
0
        // **********************************************************************

        public void Write(DateTime dateTime, AuxInfo auxInfo)
        {
            dw.WriteRecHeader(sid, dateTime);

            // --------------------------------------------------

            long         milliseconds = DateTimeHelper.ToMs(auxInfo.DateTime);
            AuxInfoFlags flags        = AuxInfoFlags.None;

            // --------------------------------------------------

            if (lastMilliseconds != milliseconds)
            {
                flags |= AuxInfoFlags.DateTime;
            }

            if (lastAskTotal != auxInfo.AskTotal)
            {
                flags |= AuxInfoFlags.AskTotal;
            }

            if (lastBidTotal != auxInfo.BidTotal)
            {
                flags |= AuxInfoFlags.BidTotal;
            }

            if (lastOI != auxInfo.OI)
            {
                flags |= AuxInfoFlags.OI;
            }

            if (lastPrice != auxInfo.Price)
            {
                flags |= AuxInfoFlags.Price;
            }

            if (lastHiLimit != auxInfo.HiLimit ||
                lastLoLimit != auxInfo.LoLimit ||
                lastDeposit != auxInfo.Deposit)
            {
                flags |= AuxInfoFlags.SessionInfo;
            }

            if (lastRate != auxInfo.Rate)
            {
                flags |= AuxInfoFlags.Rate;
            }

            if (auxInfo.Message != null)
            {
                flags |= AuxInfoFlags.Message;
            }

            // --------------------------------------------------

            dw.Write((byte)flags);

            // --------------------------------------------------

            if ((flags & AuxInfoFlags.DateTime) != 0)
            {
                dw.WriteGrowing(milliseconds, ref lastMilliseconds);
            }

            if ((flags & AuxInfoFlags.AskTotal) != 0)
            {
                dw.WriteLeb128(auxInfo.AskTotal - lastAskTotal);
                lastAskTotal = auxInfo.AskTotal;
            }

            if ((flags & AuxInfoFlags.BidTotal) != 0)
            {
                dw.WriteLeb128(auxInfo.BidTotal - lastBidTotal);
                lastBidTotal = auxInfo.BidTotal;
            }

            if ((flags & AuxInfoFlags.OI) != 0)
            {
                dw.WriteLeb128(auxInfo.OI - lastOI);
                lastOI = auxInfo.OI;
            }

            if ((flags & AuxInfoFlags.Price) != 0)
            {
                dw.WriteLeb128(auxInfo.Price - lastPrice);
                lastPrice = auxInfo.Price;
            }

            if ((flags & AuxInfoFlags.SessionInfo) != 0)
            {
                dw.WriteLeb128(auxInfo.HiLimit);
                dw.WriteLeb128(auxInfo.LoLimit);
                dw.Write(auxInfo.Deposit);

                lastHiLimit = auxInfo.HiLimit;
                lastLoLimit = auxInfo.LoLimit;
                lastDeposit = auxInfo.Deposit;
            }

            if ((flags & AuxInfoFlags.Rate) != 0)
            {
                dw.Write(auxInfo.Rate);
                lastRate = auxInfo.Rate;
            }

            if ((flags & AuxInfoFlags.Message) != 0)
            {
                dw.Write(auxInfo.Message);
            }

            // --------------------------------------------------
        }