コード例 #1
0
        }     //

        public bool TryLookupInstrumentDetails(MistyProds.InstrumentName instrName, out InstrumentDetails details)
        {
            details = null;
            lock (m_InstrumentLock)
            {
                if (!m_InstrumentDetails.TryGetValue(instrName, out details))
                {
                    details = null;
                }
            } //lock
            return(details != null);
        }     //TryGetInstrument()
コード例 #2
0
        //
        //
        // *****************************************************************
        // ****              Try Lookup Instrument()                    ****
        // *****************************************************************
        public bool TryLookupInstrument(InstrumentKey ttInstrumentKey, out InstrumentName instrument)
        {
            bool isFound = false;

            instrument = new MistyProds.InstrumentName();
            lock (m_InstrumentLock)
            {
                foreach (InstrumentName instr in m_InstrumentDetails.Keys)
                {
                    if (m_InstrumentDetails[instr].Key.Equals(ttInstrumentKey))
                    {
                        instrument = instr;
                        isFound    = true;
                        break;
                    }
                }
            } //lock
            return(isFound);
        }     //
コード例 #3
0
        }     //ProcessHubRequestInstruments()

        //
        //
        //
        // *************************************************************************
        // ****                 Process Hub Request Instruments()               ****
        // *************************************************************************
        private void ProcessHubRequestInstrumentPrice(Misty.Lib.MarketHubs.MarketHubRequest request)
        {
            if (request.Data == null || request.Data.Count < 1)
            {
                return;
            }
            foreach (object dataObj in request.Data)
            {
                Type dataType = dataObj.GetType();
                if (dataType == typeof(InstrumentName))
                {
                    InstrumentName    instr = (InstrumentName)dataObj;
                    InstrumentDetails details;
                    lock (m_InstrumentLock)
                    {
                        if (m_InstrumentDetails.TryGetValue(instr, out details))
                        {     // found desired instrument.
                            if (m_InstrumentMarkets.ContainsKey(instr))
                            { // We have already subscribed to this instrument.
                                Log.NewEntry(LogLevel.Minor, "ProcessHubRequestInstrumentPrice: We already have a subscription to {0}. Ignore request {1}.", instr.SeriesName, request.ToString());
                            }
                            else
                            {                            // We do not have a subscription to this instrument.
                                TryCreateNewBook(instr); // m_InstrumentDetails[instr].Key.MarketKey.Name);
                                m_PriceListener.SubscribeTo(details.Key, new PriceSubscriptionSettings(PriceSubscriptionType.InsideMarket));
                            }
                        }
                        else
                        {   // The user has not previously request info about this Product family.
                            //Log.NewEntry(LogLevel.Warning, "ProcessHubRequestInstrumentPrice: Failed to locate TT version of {0} for request {1}.", instr.SeriesName, request.ToString());
                        }
                    }
                }
                else if (dataType == typeof(InstrumentKey))
                {
                    InstrumentKey instrKey = (InstrumentKey)dataObj;
                    lock (m_InstrumentLock)
                    {
                        bool           isFoundInstrument = false;
                        InstrumentName instrName         = new MistyProds.InstrumentName();
                        foreach (InstrumentName i in m_InstrumentDetails.Keys)
                        {
                            if (m_InstrumentDetails[i].Key.Equals(instrKey))
                            {
                                instrName         = i;
                                isFoundInstrument = true;
                                break;
                            }
                        }
                        if (!isFoundInstrument)
                        {   // Unknown instrument.
                            Log.NewEntry(LogLevel.Warning, "ProcessHubRequestInstrumentPrice: Price subscription request with unknown instrKey = {0}", instrKey.ToString());
                        }
                        else
                        {   // We actually know this instrument.
                            if (!m_InstrumentMarkets.ContainsKey(instrName))
                            {
                                TryCreateNewBook(instrName);     //, m_InstrumentDetails[instrName].Key.MarketKey.Name);
                                m_PriceListener.SubscribeTo(instrKey, new PriceSubscriptionSettings(PriceSubscriptionType.InsideMarket));
                            }
                        }
                    }
                }
                else
                {
                    Log.NewEntry(LogLevel.Warning, "ProcessHubRequestInstrumentPrice: Failed to recognize data object {0} for request {1}.", dataType.Name, request.ToString());
                }
            } //next data
        }     // ProcessHubRequestInstrumentPrice()