void iqFeed_IQUpdateMessage(object sender, IQSummaryEventArgs e) { if (!connected) { return; } TickData tick = new TickData(); List<TickData> ticks = new List<TickData>(); if (e.SummaryMessage.Level1.LastTradeTime == DateTime.MinValue) { Console.WriteLine("UpdateMessage DateTime.MinValue encountered for tickType " + e.SummaryMessage.Level1.UpdateType.ToString()); } switch (e.SummaryMessage.Level1.UpdateType) { case UpdateType.AskUpdate: tick.tickType = TickType.Ask; tick.size = (ulong)e.SummaryMessage.Level1.AskSize; tick.price = e.SummaryMessage.Level1.Ask; tick.time = e.SummaryMessage.Level1.LastTradeTime; ticks.Add(tick); break; case UpdateType.BidUpdate: tick.tickType = TickType.Bid; tick.size = (ulong)e.SummaryMessage.Level1.BidSize; tick.price = e.SummaryMessage.Level1.Bid; tick.time = e.SummaryMessage.Level1.LastTradeTime; ticks.Add(tick); // I never get an "AskUpdate" it appears, so I'm going to update // the bid and ask here TickData askTick = new TickData(); askTick.tickType = TickType.Ask; askTick.size = (ulong)e.SummaryMessage.Level1.AskSize; askTick.price = e.SummaryMessage.Level1.Ask; askTick.time = e.SummaryMessage.Level1.LastTradeTime; ticks.Add(askTick); break; case UpdateType.TradeUpdate: tick.tickType = TickType.Trade; tick.size = e.SummaryMessage.Level1.LastSize; tick.price = e.SummaryMessage.Level1.LastPrice; tick.time = e.SummaryMessage.Level1.LastTradeTime; ticks.Add(tick); break; default: break; } if (ticks.Count > 0) { Symbol symbol = symbolMapping[e.SummaryMessage.Level1.SymbolString]; ProcessTicks(symbol, ticks); } }
void iqFeed_IQSummaryMessage(object sender, IQSummaryEventArgs e) { if (!connected) { return; } TickData bid = new TickData(); TickData ask = new TickData(); List<TickData> ticks = new List<TickData>(); bid.tickType = TickType.Bid; ask.tickType = TickType.Ask; bid.price = e.SummaryMessage.Level1.Bid; ask.price = e.SummaryMessage.Level1.Ask; bid.size = (ulong)e.SummaryMessage.Level1.BidSize; ask.size = (ulong)e.SummaryMessage.Level1.AskSize; if (e.SummaryMessage.Level1.LastTradeTime == DateTime.MinValue) { Console.WriteLine("Summary Message DateTime.MinValue encountered for tickType " + e.SummaryMessage.Level1.UpdateType.ToString()); } if (e.SummaryMessage.Level1.LastTradeTime != DateTime.MinValue) { bid.time = ask.time = e.SummaryMessage.Level1.LastTradeTime; lastGoodTickTime = e.SummaryMessage.Level1.LastTradeTime; } else { bid.time = ask.time = lastGoodTickTime; } TickData totalVolume = new TickData(); totalVolume.size = e.SummaryMessage.Level1.TotalVolume; totalVolume.time = lastGoodTickTime; totalVolume.tickType = TickType.DailyVolume; TickData lastPrice = new TickData(); lastPrice.tickType = TickType.Trade; lastPrice.time = lastGoodTickTime; lastPrice.price = e.SummaryMessage.Level1.LastPrice; TickData prevClose = new TickData(); prevClose.tickType = TickType.PreviousClose; prevClose.time = lastGoodTickTime; prevClose.price = e.SummaryMessage.Level1.LastPrice - e.SummaryMessage.Level1.TodaysChange; TickData open = new TickData(); open.tickType = TickType.OpenPrice; open.time = lastGoodTickTime; open.price = e.SummaryMessage.Level1.Open; TickData high = new TickData(); high.tickType = TickType.HighPrice; high.time = lastGoodTickTime; high.price = e.SummaryMessage.Level1.High; TickData low = new TickData(); low.tickType = TickType.LowPrice; low.price = e.SummaryMessage.Level1.Low; low.time = lastGoodTickTime; ticks.Add(bid); ticks.Add(ask); ticks.Add(totalVolume); ticks.Add(lastPrice); ticks.Add(prevClose); ticks.Add(open); ticks.Add(high); ticks.Add(low); Symbol symbol = symbolMapping[e.SummaryMessage.Level1.SymbolString]; ProcessTicks(symbol, ticks); }