Example #1
0
        internal void applyUpdateAndRaiseEvent(SimpleMDQuoteUpdate update)
        {
            switch (update.Type)
            {
                case UpdateType.QuoteBidQty:
                    BidQty = update.BidQty;
                    break;
                case UpdateType.QuoteBidQtyAndPrice:
                    BidQty = update.BidQty;
                    BidPrice = update.BidPrice;
                    break;
                case UpdateType.QuoteAskQty:
                    AskQty = update.AskQty;
                    break;
                case UpdateType.QuoteAskQtyAndPrice:
                    AskQty = update.AskQty;
                    AskPrice = update.AskPrice;
                    break;
                case UpdateType.QuoteAll:
                    BidQty = update.BidQty;
                    BidPrice = update.BidPrice;
                    AskQty = update.AskQty;
                    AskPrice = update.AskPrice;
                    break;
                default:
                    throw new FormatException("Unexpected UpdateType in SimpleQuoteModel");
            }

               // todo Updated(update.Timestamp);
        }
Example #2
0
        // todo virer le timestamp du call du scheduler, et le laisser dans les updates, car c'est le timstamp auquel on a recu l'update
        // we could do delta coding using the zigzag encoding
        private SimpleMDQuoteUpdate Run(ulong nothing)
        {
            try
            {
                SimpleMDQuoteUpdate update = new SimpleMDQuoteUpdate();
                UpdateType updateType = (UpdateType)theFile.ReadByte();
                ulong timestamp = theFile.ReadUInt64();
                switch (updateType)
                {
                    case UpdateType.QuoteBidQty:
                        {
                            uint qty = theFile.ReadUInt32();
                            update.Model = Model;
                            update.Timestamp = timestamp;
                            update.Type = updateType;
                            update.BidQty = qty;
                            update.Model = Model;
                        }
                        break;
                    case UpdateType.QuoteBidQtyAndPrice:
                        {
                            uint qty = theFile.ReadUInt32();
                            FixedPointDecimal price = theFile.ReadFixedPointDecimal();
                            update.Model = Model;
                            update.Timestamp = timestamp;
                            update.Type = updateType;
                            update.BidQty = qty;
                            update.BidPrice = price;
                            update.Model = Model;
                        }
                        break;
                    case UpdateType.QuoteAskQty:
                        {
                            uint qty = theFile.ReadUInt32();
                            update.Model = Model;
                            update.Timestamp = timestamp;
                            update.AskQty = qty;
                            update.Model = Model;
                        }
                        break;
                    case UpdateType.QuoteAskQtyAndPrice:
                        {
                            uint qty = theFile.ReadUInt32();
                            FixedPointDecimal price = theFile.ReadFixedPointDecimal();
                            update.Model = Model;
                            update.Timestamp = timestamp;
                            update.AskQty = qty;
                            update.AskPrice = price;
                            update.Model = Model;
                        }
                        break;
                    case UpdateType.QuoteAll:
                        {
                            uint bqty = theFile.ReadUInt32();
                            FixedPointDecimal bprice = theFile.ReadFixedPointDecimal();
                            uint aqty = theFile.ReadUInt32();
                            FixedPointDecimal aprice = theFile.ReadFixedPointDecimal();
                            update.Model = Model;
                            update.Timestamp = timestamp;
                            update.Type = updateType;
                            update.BidQty = bqty;
                            update.BidPrice = bprice;
                            update.AskQty = aqty;
                            update.AskPrice = aprice;
                            update.Model = Model;
                        }
                        break;
                    default:
                        throw new FormatException("Unexpected token in the feed");
                }

                return update;
            }
            catch (EndOfStreamException)
            {
                // done, nothing to do anymore
                theFile.Close();
                return null;
            }
        }