/// <summary>
        /// Find a given instrument based on the InstrumentKey.
        /// </summary>
        /// <param name="instrumentKey">InstrumentKey</param>
        private void findInstrument(InstrumentKey instrumentKey)
        {
            InstrumentLookupSubscription sub = new InstrumentLookupSubscription(m_session, m_dispatcher, instrumentKey);

            sub.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrumentLookupSubscription_Update);
            sub.Start();
        }
Пример #2
0
        private void SubscribeToInstrument(ProductKey productKey, string contract)
        {
            InstrumentLookupSubscription req = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current, productKey, contract);

            req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(req_Update);
            req.Start();
        }
Пример #3
0
        /// <summary>
        /// Event notification for status of authentication
        /// </summary>
        public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                // lookup the leg instruments

                ProductKey prodKeyLeg = new ProductKey(MarketKey.Cbot, ProductType.Future, "ZN");

                // We will use a dictionary to hold all instrument requests and update it when each instrument is found.
                // Once all lookup requests for the legs are complete, we can continue with the creation of the spread.
                // tagValue will be used in the dictionary to identify each lookup request.

                int tagValue = 1000;

                m_req1     = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, prodKeyLeg, "Mar13");
                m_req1.Tag = tagValue;
                m_spreadLegKeys.Add(tagValue, null);
                m_req1.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req1.Start();

                tagValue++;

                m_req2     = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, prodKeyLeg, "Jun13");
                m_req2.Tag = tagValue;
                m_spreadLegKeys.Add(tagValue, null);
                m_req2.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req2.Start();
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
Пример #4
0
        public void startInstrumentLookupSubscriptionsFromDataTable(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                foreach (DataRow item in TickerTable.Rows)
                {
                    ttapiTicker currentTicker;

                    if (item.Field <bool>("IsSpreadQ"))
                    {
                        currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker: item.Field <string>("Ticker"), productType: "SPREAD");
                    }
                    else
                    {
                        currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker: item.Field <string>("Ticker"), productType: "FUTURE");
                    }
                    if (currentTicker.marketKey == "CME")
                    {
                        mkey = MarketKey.Cme;
                    }
                    else if (currentTicker.marketKey == "ICE_IPE")
                    {
                        mkey = MarketKey.Ice;
                    }

                    if (currentTicker.productType == "FUTURE")
                    {
                        ptype = ProductType.Future;
                    }
                    else if (currentTicker.productType == "SPREAD")
                    {
                        ptype = ProductType.Spread;
                    }

                    InstrumentKey IKey = new InstrumentKey(new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                    Console.WriteLine(currentTicker.SeriesKey);

                    Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                    //Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(MarketKey.Cme, ProductType.Spread, "CL"), "Nov16:-1xDec16");

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

                    IlsDictionary.Add(IKey, Ils);
                    Ils.Start();
                }
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
Пример #5
0
 /// <summary>
 /// Begin work on this thread
 /// </summary>
 public void Init()
 {
     // Perform an instrument lookup
     m_req = new InstrumentLookupSubscription(m_apiInstance.Session,
                                              Dispatcher.Current,
                                              new ProductKey(m_marketKey, m_productType, m_product), m_contract);
     //m_req.Update += newEventHandler<InstrumentLookupSubscriptionEventArgs>(req_Update);
     m_req.Start();
 }
Пример #6
0
        public void FindInstrument(ProductKey productKey, string contract)
        {
            Console.WriteLine(String.Format("TT API FindInstrument {0} {1}", productKey, contract));

            InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, productKey, contract);

            instrRequest.Update += instrRequest_Completed;
            instrRequest.Start();
        }
Пример #7
0
        public void SubscribeInstrument(TTInstrument ttinstr)
        {
            cout("TengineTT: Subscribing to Instrument: {0}", ttinstr);

            InstrumentLookupSubscription req = new InstrumentLookupSubscription(m_TTAPI.Session, m_disp, ttinstr.ProductKey, ttinstr.Contract);

            req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(req_Update);
            m_lreq.Add(req);
            req.Start();
        }
Пример #8
0
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        private void FindInstrument(IList <InstrumentKey> keys)
        {
            if ((keys.Count > 0) && (keys.Count <= MAX_INSTRUMENT_COUNT))
            {
                SetComponentText(toolStripStatusLabel1, "Drag & Drop detected.  Initializing instrument...");

                // dispose of any current instrument models
                if (m_bindingModels != null)
                {
                    foreach (var entry in m_bindingModels)
                    {
                        entry.Value.ThreadID  = "";
                        entry.Value.Exchange  = "";
                        entry.Value.Product   = "";
                        entry.Value.ProdType  = "";
                        entry.Value.Contract  = "";
                        entry.Value.BidPrice  = "";
                        entry.Value.AskPrice  = "";
                        entry.Value.LastPrice = "";

                        entry.Value.Dispatcher.BeginInvokeShutdown();
                    }
                }

                // Release any current data bindings
                ReleaseDataBinding();

                // (re) instantiate our binding instrument model
                m_bindingModels = new Dictionary <InstrumentKey, InstrumentModel>(MAX_INSTRUMENT_COUNT);

                // index assigned to each instrument which corresponds to the GUI output
                int index = 1;
                foreach (InstrumentKey key in keys)
                {
                    Console.WriteLine(String.Format("TT API FindInstrument {0}", key.ToString()));

                    // create the model for the instrument & set the component data bindings
                    InstrumentModel model = new InstrumentModel(this);
                    SetDataBinding(index++, model);

                    // add the instrument model to our lookup table
                    m_bindingModels.Add(key, model);

                    // Instrument lookups are all still on the main application thread
                    InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                    instrRequest.Update += instrRequest_Completed;
                    instrRequest.Start();
                }
            }
            else
            {
                MessageBox.Show("This application accepts a maximum of " + MAX_INSTRUMENT_COUNT + " contracts.");
            }
        }
        public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            Contract C = new Contract();

            C.Init(this, MainForm, apiInstance);
            InstrumentLookupSubscription req = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current, new ProductKey("CME", "FUTURE", "HE"), "Feb19");

            req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(C.req_Update);
            req.Start();

            MainForm.XtraderConnected("HE Feb19", C);
        }
Пример #10
0
 /// <summary>
 /// Perform the instrument lookups
 /// </summary>
 public void Init()
 {
     foreach (ContractDetails cd in m_lcd)
     {
         InstrumentLookupSubscription req = new InstrumentLookupSubscription(
             m_apiInstance.Session, Dispatcher.Current,
             new ProductKey(cd.m_marketKey, cd.m_productType, cd.m_product), cd.m_contract);
         req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(req_Update);
         m_lreq.Add(req);
         req.Start();
     }
 }
        /// <summary>
        /// Launch an autospreader instrument to a selected order server.
        /// First find the instrument then launch it to the selected order feed.
        /// </summary>
        private void buttonLaunch_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection selectedCells = dataGridViewSpreadView.SelectedCells;

            if (selectedCells.Count > 0)
            {
                SpreadDetails currentSpreadDetails = ((MutableSpreadDetails)selectedCells[0].OwningRow.DataBoundItem).SpreadDetails;

                InstrumentLookupSubscription instrumentLookupSubscription = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, currentSpreadDetails.InstrumentKey);
                instrumentLookupSubscription.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrumentLookupSubscription_Update);
                instrumentLookupSubscription.Start();
            }
        }
Пример #12
0
        private void UpdateInstrumentSubscription()
        {
            InstruSubscription instru;

            if (_instruQueue.TryDequeue(out instru))
            {
                log.Info($"Suscribe to instrument: {instru.InstruId}");
                priceSub = new InstrumentLookupSubscription(_apiInstance.Session, Dispatcher.Current, new InstrumentKey(instru.Market, instru.InstruType, instru.ProductName, instru.InstruId));

                priceSub.Update += ReqUpdate;
                m_lreq.Add(priceSub);
                priceSub.Start();
            }
        }
        private void frmSOD_ManualFill_DragDrop(object sender, DragEventArgs e)
        {
            foreach (InstrumentKey key in e.Data.GetInstrumentKeys())
            {
                // Update the Status Bar text.
                UpdateStatusBar(String.Format("TT API FindInstrument {0}", key.ToString()));

                InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                instrRequest.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrRequest_Update);
                instrRequest.Start();

                // Only allow the first instrument.
                break;
            }
        }
        /// <summary>
        /// Click event which will initiate the price subscription
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConnect_Click(object sender, EventArgs e)
        {
            UpdateStatusBar("Connecting to Instrument...");

            // Create a product key from the given values
            ProductKey key = new ProductKey(this.txtExchange.Text,
                                            (ProductType)this.cboProductType.SelectedItem,
                                            this.txtProduct.Text);

            // Find out instrument based on the previously created key and the contract name
            InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(this.m_TTAPI.Session, Dispatcher.Current, key, this.txtContract.Text);

            instrRequest.Update += instrRequest_Completed;
            instrRequest.Start();
        }
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        public void FindInstrument(IList <InstrumentKey> keys)
        {
            foreach (InstrumentKey key in keys)
            {
                // Update the Status Bar text.
                UpdateStatusBar(String.Format("TT API FindInstrument {0}", key.ToString()));

                InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                instrRequest.Update += instrRequest_Completed;
                instrRequest.Tag     = key.ToString();
                instrRequest.Start();

                // Only allow the first instrument.
                break;
            }
        }
Пример #16
0
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        public void FindInstrument(IList <InstrumentKey> keys)
        {
            if (keys.Count == 1)
            {
                UpdateStatusBar("Drag & Drop detected.  Initializing instrument...");
                Console.WriteLine(String.Format("TT API FindInstrument {0}", keys[0].ToString()));

                InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, keys[0]);
                instrRequest.Update += instrRequest_Completed;
                instrRequest.Start();
            }
            else
            {
                MessageBox.Show("This application only accepts a single Contract");
            }
        }
 public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
 {
     if (e.Status.IsSuccess)
     {
         req = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current,
             new ProductKey(MarketKey.Cbot, ProductType.Future, "ZN"),
             "Sep12");
         req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(req_Update);
         req.Start();
     }
     else
     {
         Console.WriteLine("Login Failed: " + e.Status.StatusMessage);
         Dispose();
     }
 }
 void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
 {
     if (e.Status.IsSuccess)
     {
         req = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current,
                                                new ProductKey(MarketKey.Cme, ProductType.Future, "ES"),
                                                "Mar13");
         req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(req_Update);
         req.Start();
     }
     else
     {
         Console.WriteLine("Login Failed: " + e.Status.StatusMessage);
         Dispose();
     }
 }
Пример #19
0
        public void SubscribeToInstrument(InstrumentDescriptor descriptor)
        {
            if (_dispatcher.InvokeRequired())
            {
                _dispatcher.BeginInvoke(() =>
                {
                    SubscribeToInstrument(descriptor);
                });
                return;
            }

            InstrumentLookupSubscription req = new InstrumentLookupSubscription(_apiSession, Dispatcher.Current, descriptor.ProductKey, descriptor.ContractName);

            req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrumentLookupRequest_Update);
            req.Start();
        }
Пример #20
0
        /// <summary>
        /// Perform the instrument lookups
        /// </summary>
        public void Init()
        {
            foreach (ContractDetails cd in m_lcd)
            {
                InstrumentKey key = new InstrumentKey(new ProductKey(cd.m_marketKey, cd.m_productType, cd.m_product), cd.m_contract);
                Console.WriteLine("Strategy1::Subscribing to Instrument: {0}", key);

                InstrumentLookupSubscription req = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, key);

                /*InstrumentLookupSubscription req = new InstrumentLookupSubscription(
                 *  m_apiInstance.Session, Dispatcher.Current,
                 *  new ProductKey(cd.m_marketKey, cd.m_productType, cd.m_product), cd.m_contract);*/
                req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(req_Update);
                m_lreq.Add(req);
                req.Start();
            }
        }
Пример #21
0
 /// <summary>
 /// Event notification for status of authentication
 /// </summary>
 public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
 {
     if (e.Status.IsSuccess)
     {
         // lookup an instrument
         m_req = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current,
                                                  new ProductKey(MarketKey.Cbot, ProductType.Future, "ZN"),
                                                  "Sep13");
         m_req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(m_req_Update);
         m_req.Start();
     }
     else
     {
         Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
         Dispose();
     }
 }
Пример #22
0
        public void SubscribeToInstrument(InstrumentKey key)
        {
            if (_dispatcher.InvokeRequired())
            {
                _dispatcher.BeginInvoke(() =>
                {
                    SubscribeToInstrument(key);
                });
                return;
            }

            InstrumentLookupSubscription req = new InstrumentLookupSubscription(_apiSession, Dispatcher.Current, key);

            req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrumentLookupRequest_Update);
            req.Start();
            Console.WriteLine("SUBSCRIBETOINSTRUMENT REQUEST: " + key.ToString());
        }
Пример #23
0
        public void startInstrumentLookupSubscriptions(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                foreach (string dbTicker in dbTickerList)
                {
                    ttapiTicker currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker);

                    if (currentTicker.marketKey == "CME")
                    {
                        mkey = MarketKey.Cme;
                    }
                    else if (currentTicker.marketKey == "ICE_IPE")
                    {
                        mkey = MarketKey.Ice;
                    }

                    if (currentTicker.productType == "FUTURE")
                    {
                        ptype = ProductType.Future;
                    }
                    else if (currentTicker.productType == "SPREAD")
                    {
                        ptype = ProductType.Spread;
                    }

                    InstrumentKey IKey = new InstrumentKey(new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                    Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

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

                    IlsDictionary.Add(IKey, Ils);
                    Ils.Start();
                }
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
Пример #24
0
        public void CreateInstrument(string marketName, string productTypeName, string productName, string contractName, string tag)
        {
            if (_dispatcher.InvokeRequired())
            {
                _dispatcher.BeginInvoke(() =>
                {
                    CreateInstrument(marketName, productTypeName, productName, contractName, tag);
                });
                return;
            }

            InstrumentDescriptor         descriptor = new InstrumentDescriptor(marketName, productTypeName, productName, contractName);
            InstrumentLookupSubscription req        = new InstrumentLookupSubscription(_apiSession, Dispatcher.Current, descriptor.ProductKey, descriptor.ContractName);

            req.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrumentLookupRequest_Update);
            req.Tag     = tag; // Tag our request with our unique tag string
            req.Start();
            Console.WriteLine("CREATEINSTRUMENT REQUEST: " + descriptor.ToString());
        }
Пример #25
0
        public void StartASEEventChain()
        {
            int TagValue = 1;

            foreach (string dbTicker in DbTickerList)
            {
                ttapiTicker currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker);

                if (currentTicker.marketKey == "CME")
                {
                    mkey = MarketKey.Cme;
                }
                else if (currentTicker.marketKey == "ICE_IPE")
                {
                    mkey = MarketKey.Ice;
                }

                if (currentTicker.productType == "FUTURE")
                {
                    ptype = ProductType.Future;
                }
                else if (currentTicker.productType == "SPREAD")
                {
                    ptype = ProductType.Spread;
                }

                InstrumentKey IKey = new InstrumentKey(new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);
                Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                Ils.Tag = TagValue;
                SpreadLegKeys.Add(TagValue, null);
                TagValue++;

                Ils.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(CreateAutoSpreader);

                IlsDictionary.Add(IKey, Ils);
                Ils.Start();
            }
        }
Пример #26
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.    );
            }
        }
Пример #27
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;
            }
        }
Пример #28
0
        public void startInstrumentLookupSubscriptionsFromTTAPITickers(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                foreach (ttapiTicker ticker in TTAPITickerList)
                {

                    if (ticker.marketKey == "CME")
                        mkey = MarketKey.Cme;
                    else if (ticker.marketKey == "ICE_IPE")
                        mkey = MarketKey.Ice;

                    if (ticker.productType == "FUTURE")
                        ptype = ProductType.Future;
                    else if (ticker.productType == "SPREAD")
                        ptype = ProductType.Spread;

                    InstrumentKey IKey = new InstrumentKey(new ProductKey(mkey, ptype, ticker.productName), ticker.SeriesKey);
                    Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(mkey, ptype, ticker.productName), ticker.instrumentName);

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

                    IlsDictionary.Add(IKey, Ils);
                    Ils.Start();

                }
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        private void FindInstrument(IList<InstrumentKey> keys)
        {
            if ((keys.Count > 0) && (keys.Count <= MAX_INSTRUMENT_COUNT))
            {
                SetComponentText(toolStripStatusLabel1, "Drag & Drop detected.  Initializing instrument...");

                // dispose of any current instrument models
                if (m_bindingModels != null)
                {
                    foreach (var entry in m_bindingModels)
                    {
                        entry.Value.ThreadID = "";
                        entry.Value.Exchange = "";
                        entry.Value.Product = "";
                        entry.Value.ProdType = "";
                        entry.Value.Contract = "";
                        entry.Value.BidPrice = "";
                        entry.Value.AskPrice = "";
                        entry.Value.LastPrice = "";

                        entry.Value.Dispatcher.BeginInvokeShutdown();
                    }
                }

                // Release any current data bindings
                ReleaseDataBinding();

                // (re) instantiate our binding instrument model
                m_bindingModels = new Dictionary<InstrumentKey, InstrumentModel>(MAX_INSTRUMENT_COUNT);

                // index assigned to each instrument which corresponds to the GUI output
                int index = 1;
                foreach (InstrumentKey key in keys)
                {
                    Console.WriteLine(String.Format("TT API FindInstrument {0}", key.ToString()));

                    // create the model for the instrument & set the component data bindings
                    InstrumentModel model = new InstrumentModel(this);
                    SetDataBinding(index++, model);

                    // add the instrument model to our lookup table
                    m_bindingModels.Add(key, model);

                    // Instrument lookups are all still on the main application thread
                    InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                    instrRequest.Update += instrRequest_Completed;
                    instrRequest.Start();
                }
            }
            else
            {
                MessageBox.Show("This application accepts a maximum of " + MAX_INSTRUMENT_COUNT + " contracts.");
            }
        }
        private void StartSpreadDetailsProcess()
        {
            // We will create a spread with 2 legs
            Console.WriteLine("Find instruments for the legs...");

            ProductKey prodKeyLeg = new ProductKey(MarketKey.Cbot, ProductType.Future, "ZN");

            // We will use a dictionary to hold all instrument requests and update it when each instrument is found.
            // Once all lookup requests for the legs are complete, we can continue with the creation of the spread.
            // tagValue will be used in the dictionary to identify each lookup request.

            int tagValue = 1000;

            req1 = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current,
                                                prodKeyLeg,
                                                "Sep12");
            req1.Tag = tagValue;
            spreadLegKeys.Add(tagValue, null);
            req1.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(legReq_Update);
            req1.Start();

            tagValue++;

            req2 = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current,
                                                prodKeyLeg,
                                                "Dec12");
            req2.Tag = tagValue;
            spreadLegKeys.Add(tagValue, null);
            req2.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(legReq_Update);
            req2.Start();
        }
 /// <summary>
 /// Perform the instrument lookups
 /// </summary>
 public void Init()
 {
     foreach (ContractDetails cd in m_lcd)
     {
         InstrumentLookupSubscription req = new InstrumentLookupSubscription(
             m_apiInstance.Session, Dispatcher.Current,
             new ProductKey(cd.m_marketKey, cd.m_productType, cd.m_product), cd.m_contract);
         req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(req_Update);
         m_lreq.Add(req);
         req.Start();
     }
 }
Пример #32
0
        private void button1_Click(object sender, EventArgs e)
        {

            for (int i = 0; i < FilteredList.Count; i++)
            {
                if (FilteredList[i].MarketKey == "CME")
                    mkey = MarketKey.Cme;
                else if (FilteredList[i].MarketKey == "ICE_IPE")
                    mkey = MarketKey.Ice;

                if (FilteredList[i].ProductType == "FUTURE")
                    ptype = ProductType.Future;
                else if (FilteredList[i].ProductType == "SPREAD")
                    ptype = ProductType.Spread;

                m_req = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current,
                new ProductKey(mkey, ptype, FilteredList[i].ProductName),
                FilteredList[i].InstrumentName);

                m_req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req.Start();
            }

        }
        private void frmSOD_ManualFill_DragDrop(object sender, DragEventArgs e)
        {
            foreach (InstrumentKey key in e.Data.GetInstrumentKeys())
            {
                // Update the Status Bar text.
                UpdateStatusBar(String.Format("TT API FindInstrument {0}", key.ToString()));

                InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                instrRequest.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(instrRequest_Update);
                instrRequest.Start();

                // Only allow the first instrument.
                break; 
            }
        }
Пример #34
0
        }//Job
        // *****************************************************************
        // ****             Job Processing Methods                      ****
        // *****************************************************************
        /// <summary>
        /// Called by the thread's dispatcher after an outside thread has pushed a new Job.
        /// </summary>
        private void ProcessAJob()
        {
            if (m_isDisposing)
            {
                return;
            }
            Job aJob;

            while (m_InQueue.TryDequeue(out aJob))              // NET 4.5 concurrent queue. No locking needed.
            {
                m_WorkQueue.Enqueue(aJob);                      // push onto my private queue.
            }
            //
            // Process the jobs now.
            //
            while (m_WorkQueue.Count > 0)
            {
                Job job = m_WorkQueue.Dequeue();
                if (job.Product != null)
                {     //
                    if (string.IsNullOrEmpty(job.SeriesName))
                    { // User wants all instruments assoc with this product.
                        //
                        // Process Instrument Catalog requests
                        //
                        InstrumentCatalogSubscription instrumentSub = null;
                        if (!m_InstrumentCatalogs.TryGetValue(job.Product.Key, out instrumentSub))
                        {   // Failed to find a subscription.  Create a new one!
                            instrumentSub = new InstrumentCatalogSubscription(job.Product, m_Dispatcher);
                            instrumentSub.InstrumentsUpdated += InstrumentCatalog_InstrumentsUpdated;
                            instrumentSub.Start();                                                  // submit the request.
                            m_InstrumentCatalogs.Add(job.Product.Key, instrumentSub);               // store the catalog object
                            Log.NewEntry(LogLevel.Minor, "{0}: Subscribing to instr catalog for {1}.", this.Name, job.Product.Name);
                        }
                    }
                    else
                    {   // User requested Instrument info using the ProductKey and a series Name only. (Not instr Key).
                        //InstrumentLookupSubscription lookup = null;
                        Log.NewEntry(LogLevel.Major, "{0}: InstrumentLookup {1} {2}.", this.Name, job.Product, job.SeriesName);
                        InstrumentLookupSubscription subscriber = new InstrumentLookupSubscription(m_TTServices.session, m_Dispatcher, job.Product.Key, job.SeriesName);
                        subscriber.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(InstrumentLookup_InstrumentUpdated);
                        //m_InstrumentLookupsUnknown.Add(job.InstrumentKey, subscriber);
                        subscriber.Start();
                    }
                }
                else if (job.InstrumentKey != null && job.Settings == null && !job.IsTimeAndSales)
                {   //
                    // Process an Instrument information request
                    //
                    InstrumentLookupSubscription lookup = null;
                    if (!m_InstrumentLookups.TryGetValue(job.InstrumentKey, out lookup))
                    {
                        Log.NewEntry(LogLevel.Major, "{0}: InstrumentLookup {1}.", this.Name, job.InstrumentKey);
                        InstrumentLookupSubscription subscriber = new InstrumentLookupSubscription(m_TTServices.session, m_Dispatcher, job.InstrumentKey);
                        subscriber.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(InstrumentLookup_InstrumentUpdated);
                        m_InstrumentLookups.Add(job.InstrumentKey, subscriber);
                        subscriber.Start();
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Major, "{0}: InstrumentLookup {1} already submitted.", this.Name, job.InstrumentKey);
                    }
                }
                else if (job.InstrumentKey != null)
                {   //
                    // Subscribe to an instrument price
                    //
                    Instrument instrument = null;
                    InstrumentCatalogSubscription catalog       = null;                         // First, find instrument catalog for this instr.
                    InstrumentLookupSubscription  instrumentSub = null;                         // or find a specific instrument subscription.
                    //InstrumentDetails instrumentDetails = null;
                    //UVProd.InstrumentName instrumentName ;
                    if (m_InstrumentLookups.TryGetValue(job.InstrumentKey, out instrumentSub))
                    {
                        instrument = instrumentSub.Instrument;
                    }
                    else if (m_InstrumentCatalogs.TryGetValue(job.InstrumentKey.ProductKey, out catalog))
                    {
                        catalog.Instruments.TryGetValue(job.InstrumentKey, out instrument);
                    }
                    //else if (m_KeyToInstruments.TryGetValue(job.InstrumentKey, out instrumentName) && m_InstrumentDetails.TryGetValue(instrumentName, out instrumentDetails))
                    //{
                    //    m_InstrumentLookups.TryGetValue(job.InstrumentKey, out instrumentSub)
                    //}
                    else
                    {
                        Log.NewEntry(LogLevel.Minor, "{0}: I failed to find instrument key {1}.", this.Name, job.InstrumentKey.ToString());
                        return;
                    }
                    if (instrument != null)
                    {
                        if (!job.IsTimeAndSales)
                        { // this is a market data subscription request  - Subscribe or update pre-existing subscription.
                            PriceSubscription priceSub = null;
                            if (!m_PriceSubscriptions.TryGetValue(instrument.Key, out priceSub))
                            {   // Can't find a subscription, so create one.
                                Log.NewEntry(LogLevel.Major, "{0}: Creating new subscription for {1} with settings {2}.", this.Name, instrument.Name, job.Settings.PriceData);
                                priceSub = new PriceSubscription(instrument, Dispatcher.Current);
                                m_PriceSubscriptions.Add(instrument.Key, priceSub);                                      // add to our list of subscription objects.
                                if (!m_InstrKeyToVolume.ContainsKey(instrument.Key))
                                {
                                    m_InstrKeyToVolume.Add(instrument.Key, new int[4]);                                 // create a new array for volume aggregations
                                }
                                priceSub.FieldsUpdated += new FieldsUpdatedEventHandler(PriceSubscription_Updated);     // attach my handler to it.
                                priceSub.Settings       = job.Settings;
                                priceSub.Start();
                            }
                            else
                            {
                                Log.NewEntry(LogLevel.Major, "{0}: Found old subscription for {1}.  Overwriting settings {2}.", this.Name, instrument.Name, job.Settings.ToString());
                                priceSub.Settings = job.Settings;
                                priceSub.Start();
                            }
                        }
                        else
                        { // this is a time and sales data request
                            TimeAndSalesSubscription timeAndSalesSub = null;
                            if (!m_TimeAndSalesSubscriptions.TryGetValue(instrument.Key, out timeAndSalesSub))
                            {   // Can't find a subscription, so create one.
                                Log.NewEntry(LogLevel.Major, "{0}: Creating new time and sales subscription for {1}", this.Name, instrument.Name);
                                timeAndSalesSub = new TimeAndSalesSubscription(instrument, Dispatcher.Current);
                                m_TimeAndSalesSubscriptions.Add(instrument.Key, timeAndSalesSub);                       // add to our list of subscription objects.
                                if (!m_InstrKeyToVolume.ContainsKey(instrument.Key))
                                {
                                    m_InstrKeyToVolume.Add(instrument.Key, new int[4]);                                               // create a new array for volume aggregations
                                }
                                timeAndSalesSub.Update += new EventHandler <TimeAndSalesEventArgs>(TimeAndSalesSubscription_Updated); // attach my handler to it.
                                timeAndSalesSub.Start();
                            }
                            else
                            {
                                Log.NewEntry(LogLevel.Major, "{0}: Found existing time and sales subscription for {1}.", this.Name, instrument.Name, job.Settings.ToString());
                            }
                        }
                    }
                }
            } //wend Job in WorkQueue.
        }     //ProcessAJob()
Пример #35
0
        public void startInstrumentLookupSubscriptionsFromDataTable(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                foreach (DataRow item in TickerTable.Rows)
                {
                    ttapiTicker currentTicker;

                    if (item.Field<bool>("IsSpreadQ"))
                {
                    currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker: item.Field<string>("Ticker"), productType: "SPREAD");
                }
                else
                {
                    currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker: item.Field<string>("Ticker"), productType: "FUTURE");
                }
                    if (currentTicker.marketKey == "CME")
                        mkey = MarketKey.Cme;
                    else if (currentTicker.marketKey == "ICE_IPE")
                        mkey = MarketKey.Ice;

                    if (currentTicker.productType == "FUTURE")
                        ptype = ProductType.Future;
                    else if (currentTicker.productType == "SPREAD")
                        ptype = ProductType.Spread;

                    InstrumentKey IKey = new InstrumentKey(new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                    Console.WriteLine(currentTicker.SeriesKey);

                    Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                    //Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(MarketKey.Cme, ProductType.Spread, "CL"), "Nov16:-1xDec16");

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

                    IlsDictionary.Add(IKey, Ils);
                    Ils.Start();
                }
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
        /// <summary>
        /// Click event which will initiate the price subscription
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConnect_Click(object sender, EventArgs e)
        {
            UpdateStatusBar("Connecting to Instrument...");

            // Create a product key from the given values
            ProductKey key = new ProductKey(this.txtExchange.Text,
                                            (ProductType)this.cboProductType.SelectedItem,
                                            this.txtProduct.Text);

            // Find out instrument based on the previously created key and the contract name
            InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(this.m_TTAPI.Session, Dispatcher.Current, key, this.txtContract.Text);
            instrRequest.Update += instrRequest_Completed;
            instrRequest.Start();
        }
Пример #37
0
        }//Job
        // *****************************************************************
        // ****             Job Processing Methods                      ****
        // *****************************************************************
        /// <summary>
        /// Called by the thread's dispatcher after an outside thread has pushed a new Job.
        /// </summary>
        private void ProcessAJob()
        {
            if (m_isDisposing)
            {
                return;
            }
            Job aJob;

            while (m_InQueue.TryDequeue(out aJob))              // NET 4.5 concurrent queue. No locking needed.
            {
                m_WorkQueue.Enqueue(aJob);                      // push onto my private queue.
            }
            //
            // Process the jobs now.
            //
            while (m_WorkQueue.Count > 0)
            {
                Job job = m_WorkQueue.Dequeue();
                if (job.Product != null)
                {   //
                    // Process Instrument Catalog requests
                    //
                    InstrumentCatalogSubscription instrumentSub = null;
                    if (!m_InstrumentCatalogs.TryGetValue(job.Product.Key, out instrumentSub))
                    {   // Failed to find a subscription.  Create a new one!
                        instrumentSub = new InstrumentCatalogSubscription(job.Product, m_Dispatcher);
                        instrumentSub.InstrumentsUpdated += InstrumentCatalog_InstrumentsUpdated;
                        instrumentSub.Start();                                                  // submit the request.
                        m_InstrumentCatalogs.Add(job.Product.Key, instrumentSub);               // store the catalog object
                        Log.NewEntry(LogLevel.Minor, "{0}: Subscribing to instr catalog for {1}.", this.Name, job.Product.Name);
                    }
                }
                else if (job.InstrumentKey != null && job.Settings == null)
                {   //
                    // Process an Instrument information request
                    //
                    InstrumentLookupSubscription lookup = null;
                    if (!m_InstrumentLookups.TryGetValue(job.InstrumentKey, out lookup))
                    {
                        Log.NewEntry(LogLevel.Major, "{0}: InstrumentLookup {1}.", this.Name, job.InstrumentKey);
                        InstrumentLookupSubscription subscriber = new InstrumentLookupSubscription(m_TTServices.session, m_Dispatcher, job.InstrumentKey);
                        subscriber.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(InstrumentLookup_InstrumentUpdated);
                        m_InstrumentLookups.Add(job.InstrumentKey, subscriber);
                        subscriber.Start();
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Major, "{0}: InstrumentLookup {1} already submitted.", this.Name, job.InstrumentKey);
                    }
                }
                else if (job.InstrumentKey != null)
                {   //
                    // Subscribe to an instrument
                    //
                    Instrument instrument = null;
                    InstrumentCatalogSubscription catalog       = null;                         // First, find instrument catalog for this instr.
                    InstrumentLookupSubscription  instrumentSub = null;                         // or find a specific instrument subscription.
                    if (m_InstrumentLookups.TryGetValue(job.InstrumentKey, out instrumentSub))
                    {
                        instrument = instrumentSub.Instrument;
                    }
                    else if (m_InstrumentCatalogs.TryGetValue(job.InstrumentKey.ProductKey, out catalog))
                    {
                        catalog.Instruments.TryGetValue(job.InstrumentKey, out instrument);
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Minor, "{0}: I failed to find instrument key {1}.", this.Name, job.InstrumentKey.ToString());
                        return;
                    }
                    if (instrument != null)
                    {
                        // Subscribe or update pre-existing subscription.
                        PriceSubscription priceSub = null;
                        if (!m_PriceSubscriptions.TryGetValue(instrument.Key, out priceSub))
                        {   // Can't find a subscription, so create one.
                            Log.NewEntry(LogLevel.Major, "{0}: Creating new subscription for {1} with settings {2}.", this.Name, instrument.Name, job.Settings.PriceData);
                            priceSub = new PriceSubscription(instrument, Dispatcher.Current);
                            m_PriceSubscriptions.Add(instrument.Key, priceSub);                                     // add to our list of subscription objects.
                            priceSub.FieldsUpdated += new FieldsUpdatedEventHandler(PriceSubscription_Updated);     // attach my handler to it.
                            priceSub.Settings       = job.Settings;
                            priceSub.Start();
                        }
                        else
                        {
                            Log.NewEntry(LogLevel.Major, "{0}: Found old subscription for {1}.  Overwriting settings {2}.", this.Name, instrument.Name, job.Settings.ToString());
                            priceSub.Settings = job.Settings;
                            priceSub.Start();
                        }
                    }
                }
            } //wend Job in WorkQueue.
        }     //ProcessAJob()
        /// <summary>
        /// Launch an autospreader instrument to a selected order server.
        /// First find the instrument then launch it to the selected order feed.
        /// </summary>
        private void buttonLaunch_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection selectedCells = dataGridViewSpreadView.SelectedCells;
            if (selectedCells.Count > 0)
            {
                SpreadDetails currentSpreadDetails = ((MutableSpreadDetails)selectedCells[0].OwningRow.DataBoundItem).SpreadDetails;

                InstrumentLookupSubscription instrumentLookupSubscription = new InstrumentLookupSubscription(m_session, m_dispatcher, currentSpreadDetails.InstrumentKey);
                instrumentLookupSubscription.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(instrumentLookupSubscription_Update);
                instrumentLookupSubscription.Start();
            }
        }
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        public void FindInstrument(IList<InstrumentKey> keys)
        {
            if (keys.Count == 1)
            {
                UpdateStatusBar("Drag & Drop detected.  Initializing instrument...");
                Console.WriteLine(String.Format("TT API FindInstrument {0}", keys[0].ToString()));

                InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, keys[0]);
                instrRequest.Update += instrRequest_Completed;
                instrRequest.Start();
            }
            else
            {
                MessageBox.Show("This application only accepts a single Contract");
            }
        }
Пример #40
0
 private void Form1_DragDrop(object sender, DragEventArgs e)
 {
     // If the Drop-data contains at least one contract, ...
     if (e.Data.HasInstrumentKeys())
     {
         label2.Text = "";
         foreach (InstrumentKey ik in e.Data.GetInstrumentKeys())
         {
             // Begin an instrument subscription
             req = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current, ik);
             req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(req_Update);
             req.Start();
         }
     }
 }
 /// <summary>
 /// Find a given instrument based on the InstrumentKey.
 /// </summary>
 /// <param name="instrumentKey">InstrumentKey</param>
 private void findInstrument(InstrumentKey instrumentKey)
 {
     InstrumentLookupSubscription sub = new InstrumentLookupSubscription(m_session, m_dispatcher, instrumentKey);
     sub.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(instrumentLookupSubscription_Update);
     sub.Start();
 }
 /// <summary>
 /// Function to find a list of InstrumentKeys.
 /// </summary>
 /// <param name="keys">List of InstrumentKeys.</param>
 public void FindInstrument(IList<InstrumentKey> keys)
 {
     foreach (InstrumentKey key in keys)
     {
         // Update the Status Bar text.
         UpdateStatusBar(String.Format("TT API FindInstrument {0}", key.ToString()));
         
         InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
         instrRequest.Update += instrRequest_Completed;
         instrRequest.Tag = key.ToString();
         instrRequest.Start();
         
         // Only allow the first instrument.
         break;
     }
 }
Пример #43
0
        public void StartASEEventChain()
        {
                int TagValue = 1;

                foreach (string dbTicker in DbTickerList)
                {
                    ttapiTicker currentTicker = TA.TickerConverters.ConvertFromDbTicker2ttapiTicker(dbTicker);

                    if (currentTicker.marketKey == "CME")
                        mkey = MarketKey.Cme;
                    else if (currentTicker.marketKey == "ICE_IPE")
                        mkey = MarketKey.Ice;

                    if (currentTicker.productType == "FUTURE")
                        ptype = ProductType.Future;
                    else if (currentTicker.productType == "SPREAD")
                        ptype = ProductType.Spread;

                    InstrumentKey IKey = new InstrumentKey(new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);
                    Ils = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, new ProductKey(mkey, ptype, currentTicker.productName), currentTicker.SeriesKey);

                    Ils.Tag = TagValue;
                    SpreadLegKeys.Add(TagValue, null);
                    TagValue++;

                    Ils.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(CreateAutoSpreader);
                    
                    IlsDictionary.Add(IKey, Ils);
                    Ils.Start();
                }
        }
 /// <summary>
 /// Event notification for status of authentication
 /// </summary>
 public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
 {
     if (e.Status.IsSuccess)
     {
         // lookup an instrument
         m_req = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current,
             new ProductKey(MarketKey.Cme, ProductType.Future, "ES"),
             "Mar13");
         m_req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(m_req_Update);
         m_req.Start();
     }
     else
     {
         Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
         Dispose();
     }
 }
Пример #45
0
        void processFill(FillOriginator originator, FillAction action, Fill fill)
        {
            /*
             * fill.BuySell;
             * fill.FFT2;
             * fill.FFT3;
             * fill.FillKey;
             * fill.FillType;
             * fill.InstrumentKey;
             * fill.IsHedge;   // autospreader hedge order
             * fill.IsQuoting; // autospreader quoting order
             * fill.MatchPrice;
             * fill.Quantity;
             * fill.SpreadId;
             * fill.TransactionDateTime;
             */

            // If this is the first fill for this instrument, then add it to our list and
            // subscribe to the instrument updates.
            if (!instruments.ContainsKey(fill.InstrumentKey))
            {
                InstrumentLookupSubscription ils = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current, fill.InstrumentKey);
                ils.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(ils_Update);
                ils.Start();

                InstrumentInfo info = new InstrumentInfo(fill.InstrumentKey);
                instruments.Add(fill.InstrumentKey, info);
            }

            // Display the fill in the grid and play and sounds and/or send any messages related to
            // this fill.
            FillBasic fb = new FillBasic(fill);

            displayFill(fillGrid, fb);
            UpdateFillCount(fillGrid.Rows.Count);
            UpdateProfit(0);

            // See if this fill contains our '#' hashtag in either FFT field.
            string hashField = null;

            if (fill.FFT2.StartsWith("#"))
            {
                hashField = fill.FFT2;
            }
            if (fill.FFT3.StartsWith("#"))
            {
                hashField = fill.FFT3;
            }

            // If we found a valid '#' hashtag value, then put it in our dropdown combo box.
            if (hashField != null)
            {
                // Add this fill to our list of fills with this same hashsymbol
                if (!hashSymbols.ContainsKey(hashField))
                {
                    hashSymbols.Add(hashField, new List <Fill>());
                }
                List <Fill> fills = hashSymbols[hashField];
                fills.Add(fill);

                // Add this hashsymbol to our dropdown list if it is not already there
                if (!tscomboFFT.Items.Contains(hashField))
                {
                    tscomboFFT.Items.Add(hashField);
                }

                // If the user is filtering by this hash symbol then put this fill in the filter grid also
                string selectedHash = tscomboFFT.SelectedItem as string;
                if (selectedHash != null && selectedHash.Equals(hashField))
                {
                    displayFill(filteredGrid, fb);
                }
            }
        }
Пример #46
0
        /// <summary>
        /// Event notification for status of authentication
        /// </summary>
        public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                // lookup an instrument
                m_req = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current,
                    new ProductKey(MarketKey.Cme, ProductType.Spread, "CL"),
                    "Calendar: 1xCL Nov16:-1xDec16");
                m_req.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req.Start();

                m_fs = new FillsSubscription(m_apiInstance.Session, Dispatcher.Current);
                m_fs.FillAdded += new EventHandler<FillAddedEventArgs>(m_fs_FillAdded);
                m_fs.Start();
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
Пример #47
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>
        /// Event notification for status of authentication
        /// </summary>
        public void apiInstance_AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                // lookup the leg instruments

                ProductKey prodKeyLeg = new ProductKey(MarketKey.Cbot, ProductType.Future, "ZN");

                // We will use a dictionary to hold all instrument requests and update it when each instrument is found.
                // Once all lookup requests for the legs are complete, we can continue with the creation of the spread.
                // tagValue will be used in the dictionary to identify each lookup request.

                int tagValue = 1000;

                m_req1 = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, prodKeyLeg, "Mar13");
                m_req1.Tag = tagValue;
                m_spreadLegKeys.Add(tagValue, null);
                m_req1.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req1.Start();

                tagValue++;

                m_req2 = new InstrumentLookupSubscription(m_apiInstance.Session, Dispatcher.Current, prodKeyLeg, "Jun13");
                m_req2.Tag = tagValue;
                m_spreadLegKeys.Add(tagValue, null);
                m_req2.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(m_req_Update);
                m_req2.Start();
            }
            else
            {
                Console.WriteLine("TT Login failed: {0}", e.Status.StatusMessage);
                Dispose();
            }
        }
Пример #49
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.    );
                
            }
        }