}//ProcessMarketCatalogUpdate()

        //
        // *****************************************************************
        // ****             ProcessProductCatalogUpdate()               ****
        // *****************************************************************
        /// <summary>
        /// TT sent us a ProductCatalogUpdate event. Update our list of internal products.
        /// Called by hub thread.
        /// </summary>
        /// <param name="eventArg"></param>
        private void ProcessProductCatalogUpdate(ProductCatalogUpdatedEventArgs eventArg)
        {
            List <Misty.Lib.Products.Product> productList = new List <MistyProds.Product>();

            foreach (Product ttProduct in eventArg.Added)                    // loop thru each ttProduct found in event.
            {
                Misty.Lib.Products.Product ourProduct;
                if (TTConvert.TryConvert(ttProduct, out ourProduct)) // Create one of our product objects for each.
                {                                                    // Success!
                    productList.Add(ourProduct);
                    Log.NewEntry(LogLevel.Minor, "ProcessProductCatalogUpdate: Found product {0} -> {1}. ", ttProduct.Name, ourProduct);
                    if (!m_Products.ContainsKey(ttProduct.Key))
                    {
                        m_Products.Add(ttProduct.Key, ttProduct);           // store the actual TT product.
                        lock (m_ProductMapLock)
                        {
                            m_ProductMap.Add(ourProduct, ttProduct.Key);    // my product -->  productKey map
                            m_ProductMapKey.Add(ttProduct.Key, ourProduct); // product key --> my product map
                        }
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Warning, "ProcessProductCatalogUpdate: Received duplicate product! Received {0} <--> {1}", ttProduct.Name, ourProduct);
                    }
                }
                else
                {   // Since products include server name, there should never be two duplicates!
                    Log.NewEntry(LogLevel.Minor, "ProcessProductCatalogUpdate: Unknown product type {0}. ", ttProduct.Name);
                }
            }
            // Fire the event to our subscribers.
            OnMarketFoundResource(productList);                      // TODO: Send all products, all for this server, or just the new ones?
        }//ProcessProductCatalogUpdate()
Beispiel #2
0
        }     //InstrumentCatalog_InstrumentsUpdated()

        //
        //
        private void InstrumentLookup_InstrumentUpdated(object sender, InstrumentLookupSubscriptionEventArgs eventArgs)
        {
            if (eventArgs.Instrument != null && eventArgs.Error == null)
            {
                MistyProd.InstrumentName instrName;
                Instrument ttInstrument = eventArgs.Instrument;
                if (TTConvert.TryConvert(ttInstrument, out instrName))
                {   // Success in converting to our internal naming scheme.
                    InstrumentDetails details;
                    if (m_InstrumentDetails.TryGetValue(instrName, out details))
                    {   // This instrument was already added!
                        if (!ttInstrument.Key.Equals(details.Key))
                        {
                            Log.NewEntry(LogLevel.Warning, "{0}: Instrument {1} found before with non-unique key {2}!", this.Name, instrName.FullName, instrName.SeriesName);
                        }
                        else
                        {
                            Log.NewEntry(LogLevel.Warning, "{0}: Instrument {1} found before and keys match! Good.", this.Name, instrName.FullName);
                        }
                    }
                    else
                    {
                        m_KeyToInstruments.Add(ttInstrument.Key, instrName);
                        m_InstrumentDetails.Add(instrName, ttInstrument.InstrumentDetails);
                        Log.NewEntry(LogLevel.Minor, "{0}: Instruments found {1} <---> {2}.", this.Name, instrName, ttInstrument.Key.ToString());
                    }
                }
                else
                {   // Failed to convert TT instrument to a Misty Instrument.
                    // This happens because either their name is too confusing to know what it is.
                    // Or, more likely, we are set to ignore the product type (options, equity, swaps).
                    Log.NewEntry(LogLevel.Warning, "{0}: Instrument creation failed for {1}.", this.Name, ttInstrument.Key.ToString());
                }
                OnInstrumentsFound();
            }
            else if (eventArgs.IsFinal)
            {   // Instrument was not found and TTAPI has given up on looking.
                if (eventArgs.Instrument != null)
                {
                    Log.NewEntry(LogLevel.Warning, "{0}: TTAPI gave up looking for {1}.", this.Name, eventArgs.Instrument.Key.ToString());
                }
                else
                {
                    Log.NewEntry(LogLevel.Warning, "{0}: TTAPI gave up looking for something. ", this.Name, eventArgs.RequestInfo.ToString());
                }
            }
        }//InstrumentLookup_Callback()
Beispiel #3
0
        }     //ProcessAJob()

        //

        //
        #endregion// private methods



        #region TT Callback Event Handlers
        // *****************************************************************************
        // ****                     TT Callback Event Handlers                      ****
        // *****************************************************************************
        /// <summary>
        /// Using TT's dispatcher model, the thread in these methods is my local thread.
        /// </summary>
        private void InstrumentCatalog_InstrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs eventArgs)
        {
            if (m_isDisposing)
            {
                return;
            }
            if (eventArgs.Error != null)
            {
                Log.NewEntry(LogLevel.Warning, "{0}: Error in instrument catalog {1}.", this.Name, eventArgs.Error.Message);
                return;
            }
            //
            foreach (Instrument ttInstrument in eventArgs.Added)
            {
                MistyProd.InstrumentName instrName;
                if (TTConvert.TryConvert(ttInstrument, out instrName))
                {   // Success in converting to our internal type.
                    InstrumentDetails details;
                    if (m_InstrumentDetails.TryGetValue(instrName, out details))
                    {                                                               // This instrument was already added!
                        if (!ttInstrument.Key.Equals(details.Key))
                        {
                            Log.NewEntry(LogLevel.Warning, "{0}: Instrument {1} found before with non-unique key {2}!", this.Name, instrName.FullName, instrName.SeriesName);
                        }
                        else
                        {
                            Log.NewEntry(LogLevel.Warning, "{0}: Instrument {1} found before and keys match! Good.", this.Name, instrName.FullName);
                        }
                    }
                    else
                    {
                        m_KeyToInstruments.Add(ttInstrument.Key, instrName);
                        m_InstrumentDetails.Add(instrName, ttInstrument.InstrumentDetails);
                        Log.NewEntry(LogLevel.Minor, "{0}: Instruments found {1} <---> {2}.", this.Name, instrName, ttInstrument.Key.ToString());
                    }
                }
                else
                {   // Failed to convert TT instrument to a Misty Instrument.
                    // This happens because either their name is too confusing to know what it is.
                    // Or, more likely, we are set to ignore the product type (options, equity, swaps).
                    Log.NewEntry(LogLevel.Warning, "{0}: Instrument creation failed for {1}.", ttInstrument.Key.ToString());
                }
            } // next instr added
            OnInstrumentsFound();                                                       // Trigger event for subscribers
        }     //InstrumentCatalog_InstrumentsUpdated()