示例#1
0
        private void OnBulkLevel2Update(csBulkLevel2UpdateEventArgs o)
        {
            EventHandler <csBulkLevel2UpdateEventArgs> temp = bulkLevel2UpdateEvent;

            if (temp != null)
            {
                temp(this, o);
            }
        }
示例#2
0
        } // thread terminates

        #endregion


        #region ProcessData
        /// <summary>
        /// Processes the data and fires appropriate update events to subscribers.
        /// </summary>
        /// <param name="dataToProcess"></param>
        private void ProcessData(DateTime timeOfUpdate, List <byte[]> dataToProcess, List <ushort> typesToProcess)
        {
            csBulkLevel1UpdateEventArgs level1Updates = new csBulkLevel1UpdateEventArgs(timeOfUpdate, new List <byte[]>(), new List <ushort>());
            csBulkLevel2UpdateEventArgs level2Updates = new csBulkLevel2UpdateEventArgs(timeOfUpdate, new List <byte[]>(), new List <ushort>());

            for (int i = 0; i < typesToProcess.Count; i++)
            {
                //if statements are ordered in order of frequency of occurrence...
                if (typesToProcess[i] == csHeader.MARKET_DEPTH_INCREMENTAL_UPDATE_COMPACT)
                {
                    level2Updates.AddUpdate(dataToProcess[i]);
                    level2Updates.AddUpdateType(typesToProcess[i]);
                }
                else if (typesToProcess[i] == csHeader.QUOTE_INCREMENTAL_UPDATE_COMPACT)
                {
                    level1Updates.AddUpdate(dataToProcess[i]);
                    level1Updates.AddUpdateType(typesToProcess[i]);

                    //for now since they are not included in 'detph' updates we include them there too
                    //now, it claims to be fixed...so remove it
                    //level2Updates.AddUpdate(dataToProcess[i]);
                    //level2Updates.AddUpdateType(typesToProcess[i]);
                }
                else if (typesToProcess[i] == csHeader.TRADE_INCREMENTAL_UPDATE_COMPACT)
                {
                    level1Updates.AddUpdate(dataToProcess[i]);
                    level1Updates.AddUpdateType(typesToProcess[i]);
                }
                else if (typesToProcess[i] == csHeader.MARKET_DEPTH_SNAPSHOT_LEVEL)
                {
                    level2Updates.AddUpdate(dataToProcess[i]);
                    level2Updates.AddUpdateType(typesToProcess[i]);
                }
                else if (typesToProcess[i] == csHeader.SECURITY_DEFINITION_RESPONSE)
                {//here need to find the correspondence of marketSymbolID and its string
                    try
                    {
                        csHeader.s_SecurityDefinitionResponse securityResponse = new csHeader.s_SecurityDefinitionResponse();
                        securityResponse.CopyFromManual(dataToProcess[i]);
                        //securityResponse.RequestID//this is then used as 'marketSymbolID
                        while (instrumentFromDTCMarketSymbolID.Count <= securityResponse.RequestID)
                        {
                            instrumentFromDTCMarketSymbolID.Add(string.Empty);
                        }

                        instrumentFromDTCMarketSymbolID[securityResponse.RequestID] = securityResponse.Symbol;

                        //create a copy of this list
                        List <string> copy = new List <string>(instrumentFromDTCMarketSymbolID);
                        //pass it to the potential subscribers
                        OnSecurityDefinitionResponse(new csSecurityDefinitionResponseEventArgs(copy));
                    }
                    catch { }
                }
                else if (typesToProcess[i] == csHeader.HEARTBEAT)
                {
                    lock (reconnectionLogicLock)
                    {
                        secondsSinceLastServerHeartbeat = 0;
                    }
                }
                else if (typesToProcess[i] == csHeader.MARKET_DATA_FEED_STATUS)
                {
                    //see what is the status of the feed and act accordingly...
                }
            }

            if (level1Updates.Updates.Count > 0)
            {
                OnBulkLevel1Update(level1Updates);
            }
            if (level2Updates.Updates.Count > 0)
            {
                OnBulkLevel2Update(level2Updates);
            }
        }