// ********************************************************************** public OrdersStream(DataWriter dw, int sid, Security s) { this.dw = dw; this.sid = sid; dw.Write((byte)StreamType.Orders); dw.Write(s.Entry); }
// ********************************************************************** public StockStream(DataWriter dw, int sid, Security s) { this.dw = dw; this.sid = sid; dw.Write((byte)StreamType.Stock); dw.Write(s.Entry); }
// ********************************************************************** public AuxInfoStream(DataWriter dw, int sid, Security s) { this.dw = dw; this.sid = sid; dw.Write((byte)StreamType.AuxInfo); dw.Write(s.Entry); }
// ********************************************************************** public DealsStream(DataWriter dw, int sid, Security s) { this.dw = dw; this.sid = sid; this.s = s; dw.Write((byte)StreamType.Deals); dw.Write(s.Entry); }
// ********************************************************************** public MessagesStream(DataWriter dw, int sid) { this.dw = dw; this.sid = sid; dw.Write((byte)StreamType.Messages); }
// ********************************************************************** public QshWriter(string path, bool compress, string appName, string comment, DateTime recDateTime, int streamCount) { if(streamCount < 0) throw new ArgumentOutOfRangeException("streamCount"); if(streamCount > byte.MaxValue) throw new OverflowException("Слишком много потоков для записи"); fs = QshFile.Create(path, compress, fileVersion); dw = new DataWriter(fs, recDateTime, streamCount > 1); dw.Write(appName); dw.Write(comment); dw.Write(recDateTime.Ticks); dw.Write((byte)streamCount); }
// ********************************************************************** 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); } // -------------------------------------------------- }
// ********************************************************************** 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; } // ------------------------------------------------------------ }