Exemplo n.º 1
0
        void ics_InstrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            foreach (TradingTechnologies.TTAPI.Instrument inst in e.Added)
            {
                Console.WriteLine("Instr: {0}", inst.Name);
                //Console.WriteLine(e.GetType());

                InstrumentList.Add(inst.Name);
                //Console.WriteLine(e.    );
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// InstrumentCatalogSubscription InstrumentsUpdated event.
        /// </summary>
        private void InstrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            InstrumentCatalogSubscription instrumentCatalogSubscription = sender as InstrumentCatalogSubscription;

            if (instrumentCatalogSubscription?.Instruments?.Values != null)
            {
                foreach (Instrument instru in instrumentCatalogSubscription.Instruments.Values)
                {
                    if (!_availableInstrumentDico.ContainsKey(instru.Key.SeriesKey))
                    {
                        _availableInstrumentDico.Add(instru.Key.SeriesKey, instru);
                        InstrumentDetails instruDetails = instru.InstrumentDetails;
                        DataUpdateEvent?.Invoke(this, instruDetails.Key.SeriesKey, instruDetails.ExpirationDate.ToDateTime(), instruDetails.StrikePrice, instruDetails.OptionType.ToString().ToUpper(), instruDetails.Name, instru.Product.Type.Name, instru.Product.Name);
                    }
                }
            }
        }
Exemplo n.º 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()
Exemplo n.º 4
0
        void ics_InstrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            foreach (TradingTechnologies.TTAPI.Instrument inst in e.Added)
            {
                Console.WriteLine("Instr: {0}", inst.Name);

                //Console.WriteLine(e.GetType());
                //sw.WriteLine(inst.Name);
                //sw.Flush();

                InstrumentList.Add(inst.Name);



                m_req         = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, inst.Key);
                m_req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req.Start();


                //Console.WriteLine(e.    );
            }
        }
Exemplo n.º 5
0
        public void StartInstrumentLookupSubscriptionsFromCatalog(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            foreach (TradingTechnologies.TTAPI.Instrument inst in e.Added)
            {
                Console.WriteLine("Instr: {0}", inst.Name);


                Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, inst.Key);

                for (int i = 0; i < ilsUpdateList.Count; i++)
                {
                    Ils.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(ilsUpdateList[i]);
                }

                Console.WriteLine(Ils.Instrument.Key.ToString());

                IlsDictionary.Add(inst.Key, Ils);
                Ils.Start();

                //InstrumentCatalogSubscription ics2 = (InstrumentCatalogSubscription)sender;

                //ics2.InstrumentsUpdated -= ics_InstrumentsUpdated;
                //ics2.Dispose();
                //ics2 = null;
            }

            TradingTechnologies.TTAPI.Product Prod = ((InstrumentCatalogSubscription)sender).Product;

            PlsDictionary[Prod.Key].Update -= PLSEventHandler;
            PlsDictionary[Prod.Key].Dispose();
            PlsDictionary[Prod.Key] = null;
            PlsDictionary.Remove(Prod.Key);

            if ((PlsDictionary.Count == 0) & PlsDictionaryCompleteQ)
            {
                IlsDictionaryCompleteQ = true;
            }
        }
 /// <summary>
 /// InstrumentCatalogSubscription InstrumentsUpdated event.
 /// </summary>
 private void instrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
 {
     InstrumentCatalogSubscription instrumentCatalogSubscription = sender as InstrumentCatalogSubscription;
     updateInstrumentTreeViewNodes(instrumentCatalogSubscription);
 }
Exemplo n.º 7
0
        void ics_InstrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            foreach (TradingTechnologies.TTAPI.Instrument inst in e.Added)
            {
                Console.WriteLine("Instr: {0}", inst.Name);
                //Console.WriteLine(e.GetType());

                InstrumentList.Add(inst.Name);
                //Console.WriteLine(e.    );
                
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// InstrumentCatalogSubscription InstrumentsUpdated event.
        /// </summary>
        private void instrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            InstrumentCatalogSubscription instrumentCatalogSubscription = sender as InstrumentCatalogSubscription;

            updateInstrumentTreeViewNodes(instrumentCatalogSubscription);
        }
Exemplo n.º 9
0
        public void StartInstrumentLookupSubscriptionsFromCatalog(object sender, InstrumentCatalogUpdatedEventArgs e)
        {

            foreach (TradingTechnologies.TTAPI.Instrument inst in e.Added)
            {
                Console.WriteLine("Instr: {0}", inst.Name);


                Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, inst.Key);
                
                for (int i = 0; i < ilsUpdateList.Count; i++)
                {
                    Ils.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(ilsUpdateList[i]);
                }

                Console.WriteLine(Ils.Instrument.Key.ToString());

                IlsDictionary.Add(inst.Key, Ils);
                Ils.Start();

                //InstrumentCatalogSubscription ics2 = (InstrumentCatalogSubscription)sender;

                //ics2.InstrumentsUpdated -= ics_InstrumentsUpdated;
                //ics2.Dispose();
                //ics2 = null;
            }

            TradingTechnologies.TTAPI.Product Prod = ((InstrumentCatalogSubscription)sender).Product;

            PlsDictionary[Prod.Key].Update -= PLSEventHandler;
            PlsDictionary[Prod.Key].Dispose();
            PlsDictionary[Prod.Key] = null;
            PlsDictionary.Remove(Prod.Key);

            if ((PlsDictionary.Count == 0) & PlsDictionaryCompleteQ)
            {
                IlsDictionaryCompleteQ = true;
            }


        }
Exemplo n.º 10
0
        void ics_InstrumentsUpdated(object sender, InstrumentCatalogUpdatedEventArgs e)
        {
            foreach (TradingTechnologies.TTAPI.Instrument inst in e.Added)
            {
                Console.WriteLine("Instr: {0}", inst.Name);
                
                //Console.WriteLine(e.GetType());
                //sw.WriteLine(inst.Name);
                //sw.Flush();

                InstrumentList.Add(inst.Name);



                m_req = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current,inst.Key);
                m_req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req.Start();


                //Console.WriteLine(e.    );
                
            }
        }