/// <summary>
        /// This function is called when an instrument is dragged and dropped from the 
        /// Market Grid in X_TRADER.
        /// </summary>
        private void m_TTDropHandler_OnNotifyDrop()
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Drag & Drop detected.  Initializing instrument...";

            try
            {
                if (m_TTInstrObj != null)
                {
                    // Detach previously attached instrument.
                    m_TTInstrNotify.DetachInstrument(m_TTInstrObj);
                    m_TTInstrObj = null;
                }

                // Obtain the TTInstrObj from the TTDropHandler object.
                m_TTInstrObj = (XTAPI.TTInstrObj)m_TTDropHandler[1];

                // Attach the TTInstrObj to the TTInstrNotify for price update events.
                m_TTInstrNotify.AttachInstrument(m_TTInstrObj);

                // Open the TTInstrObj.
                m_TTInstrObj.Open(0);	// enable Market Depth:  1 - true, 0 - false

                // Clear drop handler list.
                m_TTDropHandler.Reset();
            }
            catch (Exception ex)
            {
                // Display exception message.
                MessageBox.Show(ex.Message, "Exception");
            }
        }
Exemple #2
0
        private void initQuotes()
        {
            // Instantiate the instrument notification class.
            m_TTInstrNotify = new XTAPI.TTInstrNotifyClass();

            log("Loading Quotes config: " + realTimeLocation);

            string[] lines = System.IO.File.ReadAllLines(realTimeLocation);

            // Setup the instrument notification call back functions.
            m_TTInstrNotify.OnNotifyFound += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(this.m_TTInstrNotify_OnNotifyFound);
            m_TTInstrNotify.OnNotifyUpdate += new XTAPI._ITTInstrNotifyEvents_OnNotifyUpdateEventHandler(this.m_TTInstrNotify_OnNotifyUpdate);

            log("Init Depth config");
            m_TTInstrNotify.OnNotifyDepthData += new XTAPI._ITTInstrNotifyEvents_OnNotifyDepthDataEventHandler(pNotify_OnNotifyDepthData);
            m_TTInstrNotify.EnableDepthUpdates = 1;
            depths = new Hashtable(600);

            string[] conf = null;
            string raw = null;

            foreach(string line in lines) {
                try {

                    raw = line;
                    conf = line.Split(',');
                    XTAPI.TTInstrObj m_TTInstrObj = new XTAPI.TTInstrObj();
                    m_TTInstrObj.Exchange =conf[0];
                    m_TTInstrObj.Product =conf[1];
                    m_TTInstrObj.ProdType =conf[2];
                    m_TTInstrObj.Contract =conf[3];

                    m_TTInstrNotify.AttachInstrument(m_TTInstrObj);
                    // 1 authorize depth
                    //m_TTInstrObj.Open(1);
                    m_TTInstrObj.Open(0);

                    Console.WriteLine(conf[1]+" "+conf[3]+" Added");

                } catch (Exception e)
                {
                    log("Error!!! >>>"+e.Message+" "+line);
                }

            }

            log(lines.Length+" Quotes Parsed");
        }
        /// <summary>
        /// This function is called when one or more instruments are dragged and dropped from 
        /// the Market Grid in X_TRADER.
        /// </summary>
        private void m_TTDropHandler_OnNotifyDrop()
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Drag & Drop detected.  Initializing instrument...";

            // Clear items in listbox
            lboPriceList.Items.Clear();

            try
            {
                // Test if a TTInstrObj currently exists.
                if (m_TTInstrObj != null)
                {
                    // Detach previously attached instrument.
                    m_TTInstrNotify.DetachInstrument(m_TTInstrObj);
                    m_TTInstrObj = null;
                }

                // Obtain the TTInstrObj from the TTDropHandler object.
                m_TTInstrObj = (XTAPI.TTInstrObj) m_TTDropHandler[1];

                // Attach the TTInstrObj to the TTInstrNotify for price update events.
                m_TTInstrNotify.AttachInstrument(m_TTInstrObj);

                // Set an update filter to stop receiving OnPriceListUpdate for volume
                m_TTInstrNotify.UpdateFilter = "Last,LastQty,HitTake";

                // Open the TTInstrObj.
                m_TTInstrObj.Open(0);	// enable Market Depth:  1 - true, 0 - false

                // Clear drop handler list.
                m_TTDropHandler.Reset();
            }
            catch (Exception ex)
            {
                // Display exception message.
                MessageBox.Show(ex.Message, "Exception");
            }
        }
        /// <summary>
        /// Connect to the instruments
        /// </summary>
        /// <param name="sender">Object which fires the method</param>
        /// <param name="e">Event arguments of the callback</param>
        private void connectButton_Click(object sender, System.EventArgs e)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Connecting to Instrument...";

            try
            {
                if (m_TTInstrObj != null)
                {
                    // Detach previously attached instrument.
                    m_TTInstrNotify.DetachInstrument(m_TTInstrObj);
                    m_TTInstrObj = null;
                }

                // Instantiate a new instrument object.
                m_TTInstrObj = new XTAPI.TTInstrObjClass();

                // Obtain the instrument information from the user input.
                m_TTInstrObj.Exchange = txtExchange.Text;
                m_TTInstrObj.Product = txtProduct.Text;
                m_TTInstrObj.ProdType = txtProductType.Text;
                m_TTInstrObj.Contract = txtContract.Text;

                // Attach the TTInstrObj to the TTInstrNotify for price update events.
                m_TTInstrNotify.AttachInstrument(m_TTInstrObj);

                // Open the TTInstrObj.
                m_TTInstrObj.Open(0);	// enable Market Depth:  1 - true, 0 - false
            }
            catch (Exception ex)
            {
                // Display exception message.
                MessageBox.Show(ex.Message, "Exception");
            }
        }