示例#1
0
        private void M_priceFeed_OnPriceUpdate(Tools.IQFeed.PriceUpdateIQ update)
        {
            //var sUpdate = string.Format("{0},{1},{2},{3},{4},{5}", update.Symbol, update.LastTradePrice, update.Bid, update.BidSize, update.Ask, update.AskSize);
            // Prepend the CHANNEL (+space) to the string we will send:
            var sUpdate = string.Format("{0} {1}", IQ_CHANNEL, update.ToString());
            using (var updateFrame = new ZFrame(sUpdate))
            {
                //Console.WriteLine("OnPriceUpdate->" + sUpdate.ToString());
                m_publisherSocket.Send(updateFrame);
            }
            long count;
            if (m_publishCounts.TryGetValue(update.Symbol, out count))
                m_publishCounts[update.Symbol] = ++count;
            else
                m_publishCounts[update.Symbol] = 1;

            //m_publisherSocket.SendFrame(sUpdate);         // NetMQ (when testing in place of ZeroMQ)
        }
        private void M_priceFeed_UpdatePrices(Tools.IQFeed.PriceUpdateIQ update)
        {
            //var sUpdate = string.Format("{0},{1},{2},{3},{4},{5}", update.Symbol, update.LastTradePrice, update.Bid, update.BidSize, update.Ask, update.AskSize);
            var sUpdate = update.ToString();

            m_pub.PublishAsync(IQ_CHANNEL, sUpdate);
            //Console.WriteLine("PUB to channel {0} => {1}", GetChannel(update.Symbol), sUpdate);
            //Console.Write("(PUB:{0})  ", update.Symbol);
            long count;

            if (m_publishCounts.TryGetValue(update.Symbol, out count))
            {
                m_publishCounts[update.Symbol] = ++count;
            }
            else
            {
                m_publishCounts[update.Symbol] = 1;
            }
        }