/// <summary>
        /// This function is called when an instrument is found after it is opened.
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Instrument Found.";

            // Retrieve the instrument information using the TTInstrObj Get Properties.
            Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract");

            txtExchange.Text = (string)data.GetValue(0);
            txtProduct.Text = (string)data.GetValue(1);
            txtProductType.Text = (string)data.GetValue(2);
            txtContract.Text = (string)data.GetValue(3);

            // Obtain the available customer names and add them to the ComboBox.
            XTAPI.TTOrderProfileClass orderProfile = new XTAPI.TTOrderProfileClass();
            foreach (string entry in orderProfile.Customers as Array)
            {
                cboCustomer.Items.Add(entry);
            }

            // Set the first item in the customer combo boxes.
            cboCustomer.SelectedIndex = 0;

            // Set the Net Limits to false.
            m_TTOrderSet.Set("NetLimits",false);
            // Open the TTOrderSet with send orders enabled.
            m_TTOrderSet.Open(1);

            // Enable the user interface items.
            btnBuy.Enabled = true;
            btnSell.Enabled = true;
            cboCustomer.Enabled = true;
            gboDeleteOrder.Enabled = true;
            gboModifyOrder.Enabled = true;
        }
Exemple #2
0
        private void OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            try
            {
                Array data = (Array)pInstr.get_Get("Bid#,Ask#,NetPos,PL.Z,OpenPL^");

                //get currency amount of tick
                double tickvalue = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "^"));

                for (int i = 0; i < data.Length; ++i)
                    if (data.GetValue(i) == null)
                        return;

                Update update = new Update();

                update.Bid = Convert.ToDouble(data.GetValue(0));
                update.Ask = Convert.ToDouble(data.GetValue(1));
                update.NetPos = Convert.ToInt16(data.GetValue(2));
                //convert number of ticks from PL to currency
                update.PL = tickvalue * Convert.ToDouble(data.GetValue(3));
                update.OpenPL = Convert.ToDouble(data.GetValue(4));
                update.Symbol = pInstr.Product;

                if (OnUpdate != null)
                    OnUpdate(this, new UpdateEventArgs(update));
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled) log.Error(ex.StackTrace);
            }
        }
        /// <summary>
        /// This function displays is called for every change to the instrument depth.
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void pNotify_OnNotifyDepthData(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Clear the depth list boxes.
            lboBidDepth.Items.Clear();
            lboAskDepth.Items.Clear();

            // Obtain the bid depth (Level based on user selection).
            Array dataArrayBid = (Array)pInstr.get_Get(m_bidDepthValue);

            // Test if depth exists.
            if (dataArrayBid != null)
            {
                // Iterate through the depth array.
                for (int i = 0; i <= dataArrayBid.GetUpperBound(0); i++)
                {
                    // Break out of FOR LOOP if index value is null.
                    if (dataArrayBid.GetValue(i,0) == null)
                        break;

                    // Update the bid depth list box.
                    lboBidDepth.Items.Add("BidPrice: " + dataArrayBid.GetValue(i,0) +
                                          " | " +
                                          " BidQty: " + dataArrayBid.GetValue(i,1));
                }
            }

            // Obtain the ask depth (Level based on user selection).
            Array dataArrayAsk = (Array) pInstr.get_Get(m_askDepthValue);

            // Test if depth exists.
            if (dataArrayAsk != null)
            {
                // Iterate through the depth array.
                for (int i = 0; i <= dataArrayAsk.GetUpperBound(0); i++)
                {
                    // Break out of FOR LOOP if index value is null.
                    if (dataArrayAsk.GetValue(i,0) == null)
                        break;

                    // Update the bid depth list box.
                    lboAskDepth.Items.Add(" AskPrice: " + dataArrayAsk.GetValue(i,0) +
                                          " | " +
                                          " AskQty: " + dataArrayAsk.GetValue(i,1));
                }
            }
        }
        /// <summary>
        /// This function is called when an instrument update occurs (i.e. LTP changes).
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Retrieve the instrument information using the TTInstrObj Get Properties.
            Array data = (Array) pInstr.get_Get("Bid$,Ask$,Last$,Change$");

            // Populate the user interface textboxes.
            txtBidPrice.Text = (string)data.GetValue(0);
            txtAskPrice.Text = (string)data.GetValue(1);
            txtLastPrice.Text = (string)data.GetValue(2);
            txtChange.Text = (string)data.GetValue(3);
        }
        /// <summary>
        /// Publish specific information about each order to the GUI
        /// </summary>
        /// <param name="callingMethod">Method that called the publish</param>
        /// <param name="pNewOrderObj">New order object</param>
        /// <param name="pOldOrderObj">Old order object</param>
        private void PublishEventOrderData(string callingMethod, XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj)
        {
            if (pOldOrderObj.IsNull != 0)
            {
                txtOrderAuditTrail.Text += callingMethod + " - Old Order: NULL\r\n";
            }
            else
            {
                try
                {
                    Array oldOrderData = (Array)pOldOrderObj.get_Get("Acct,OrdStatus,OrdAction,Contract$,BuySell,OrderQty,Price,SiteOrderKey,OrderNo");

                    txtOrderAuditTrail.Text += callingMethod + " - Old Order: " + oldOrderData.GetValue(0).ToString() + ", " +
                                                                                  oldOrderData.GetValue(1).ToString() + ", " +
                                                                                  oldOrderData.GetValue(2).ToString() + ", " +
                                                                                  oldOrderData.GetValue(3).ToString() + ", " +
                                                                                  oldOrderData.GetValue(4).ToString() + ", " +
                                                                                  oldOrderData.GetValue(5).ToString() + ", " +
                                                                                  oldOrderData.GetValue(6).ToString() + ", " +
                                                                                  oldOrderData.GetValue(7).ToString() + ", " +
                                                                                  oldOrderData.GetValue(8).ToString() + "\r\n";
                }
                catch (Exception ex)
                {
                    txtOrderAuditTrail.Text += callingMethod + " - Old Order: Error Message - " + ex.Message + "\r\n";
                }
            }

            if (pNewOrderObj.IsNull != 0)
            {
                txtOrderAuditTrail.Text += callingMethod + " - New Order: NULL\r\n";
            }
            else
            {
                try
                {
                    Array newOrderData = (Array)pNewOrderObj.get_Get("Acct,OrdStatus,OrdAction,Contract$,BuySell,OrderQty,Price,SiteOrderKey,OrderNo");

                    txtOrderAuditTrail.Text += callingMethod + " - New Order: " + newOrderData.GetValue(0).ToString() + ", " +
                                                                                  newOrderData.GetValue(1).ToString() + ", " +
                                                                                  newOrderData.GetValue(2).ToString() + ", " +
                                                                                  newOrderData.GetValue(3).ToString() + ", " +
                                                                                  newOrderData.GetValue(4).ToString() + ", " +
                                                                                  newOrderData.GetValue(5).ToString() + ", " +
                                                                                  newOrderData.GetValue(6).ToString() + ", " +
                                                                                  newOrderData.GetValue(7).ToString() + ", " +
                                                                                  newOrderData.GetValue(8).ToString() + "\r\n";
                }
                catch (Exception ex)
                {
                    txtOrderAuditTrail.Text += callingMethod + " - New Order: Error Message - " + ex.Message + "\r\n";
                }
            }
        }
        /// <summary>
        /// Display the information from the instrument object(s) to the GUI.
        /// 
        /// Note:   The TTInstrObj Alias property set in the m_TTDropHandler.OnNotifyDrop()
        ///         is used to determine the instrument invoking the update.
        /// </summary>
        /// <param name="pInstr">TTInstrObj object</param>
        private void DisplayInstrumentInformation(XTAPI.TTInstrObj pInstr)
        {
            // Retrieve the instrument information using the TTInstrObj Get Properties.
            //
            // Note:    For simplicity, the Exchange, Product, ProdType and Contract request
            //          is redundant for market data updates.  Ideally you would only need
            //          to request this information in the OnNotifyFound event.
            Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract,Bid$,Ask$,Last$");

            // Switch is based on Alias property set during the OnNotifyDrop event
            switch (pInstr.Alias)
            {
                case "0":
                    exchangeTextBox1.Text = (string)data.GetValue(0);
                    productTextBox1.Text = (string)data.GetValue(1);
                    prodTypeTextBox1.Text = (string)data.GetValue(2);
                    contractTextBox1.Text = (string)data.GetValue(3);
                    bidPriceTextBox1.Text = (string)data.GetValue(4);
                    askPriceTextBox1.Text = (string)data.GetValue(5);
                    lastPriceTextBox1.Text = (string)data.GetValue(6);
                    break;
                case "1":
                    exchangeTextBox2.Text = (string)data.GetValue(0);
                    productTextBox2.Text = (string)data.GetValue(1);
                    prodTypeTextBox2.Text = (string)data.GetValue(2);
                    contractTextBox2.Text = (string)data.GetValue(3);
                    bidPriceTextBox2.Text = (string)data.GetValue(4);
                    askPriceTextBox2.Text = (string)data.GetValue(5);
                    lastPriceTextBox2.Text = (string)data.GetValue(6);
                    break;
                case "2":
                    exchangeTextBox3.Text = (string)data.GetValue(0);
                    productTextBox3.Text = (string)data.GetValue(1);
                    prodTypeTextBox3.Text = (string)data.GetValue(2);
                    contractTextBox3.Text = (string)data.GetValue(3);
                    bidPriceTextBox3.Text = (string)data.GetValue(4);
                    askPriceTextBox3.Text = (string)data.GetValue(5);
                    lastPriceTextBox3.Text = (string)data.GetValue(6);
                    break;
                case "3":
                    exchangeTextBox4.Text = (string)data.GetValue(0);
                    productTextBox4.Text = (string)data.GetValue(1);
                    prodTypeTextBox4.Text = (string)data.GetValue(2);
                    contractTextBox4.Text = (string)data.GetValue(3);
                    bidPriceTextBox4.Text = (string)data.GetValue(4);
                    askPriceTextBox4.Text = (string)data.GetValue(5);
                    lastPriceTextBox4.Text = (string)data.GetValue(6);
                    break;
                default:
                    MessageBox.Show("DisplayInstrumentInformation: Invalid Index");
                    break;
            }
        }
Exemple #7
0
        private void register(XTAPI.TTInstrObj pInstr)
        {
            quotes_counter +=1;

            try {

                Array data = (Array) pInstr.get_Get("Exchange,Product,Contract,Open$,High$,Low$,Last$,Close$,Settle$");

                if(quotes_counter%250==0) {
                    Console.Write('.');
                }

                quote(data);

            } catch (Exception e) {
                log("Register Error:"+">>"+e.Message);
            }
        }
        /// <summary>
        /// Display the profit and loss and net position for each instrument.
        /// </summary>
        /// <param name="pInstr">TTInstrObj object</param>
        private void DisplayPLInformation(XTAPI.TTInstrObj pInstr)
        {
            // Get the P/L and Net Position per instrument.
            Array data = (Array) pInstr.get_Get("PL$,NetPos");

            switch (pInstr.Alias)
            {
                case "0":
                    txtPL1.Text = Convert.ToString(data.GetValue(0));
                    txtNetPosition1.Text = Convert.ToString(data.GetValue(1));
                    break;
                case "1":
                    txtPL2.Text = Convert.ToString(data.GetValue(0));
                    txtNetPosition2.Text = Convert.ToString(data.GetValue(1));
                    break;
                case "2":
                    txtPL3.Text = Convert.ToString(data.GetValue(0));
                    txtNetPosition3.Text = Convert.ToString(data.GetValue(1));
                    break;
                case "3":
                    txtPL4.Text = Convert.ToString(data.GetValue(0));
                    txtNetPosition4.Text = Convert.ToString(data.GetValue(1));
                    break;
                default:
                    MessageBox.Show(this,"PL ERROR");
                    break;
            }
        }
Exemple #9
0
 private void m_TTOrderSet_OnOrderFillData(XTAPI.TTFillObj pFillObj)
 {
     // Retrieve the fill information using the TTFillObj Get Properties.
     Array fillData = (Array) pFillObj.get_Get(fillRequest);
     Console.Write('*');
     FillMessage(fillData);
 }
Exemple #10
0
        private void pNotify_OnNotifyDepthData(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            Array data = (Array) pInstr.get_Get("Exchange,Product,Contract");

            string ex = (string)data.GetValue(0);
            string product = (string)data.GetValue(1);
            string contract = (string)data.GetValue(2);

            StringBuilder idBld = new StringBuilder();
            idBld.Append(ex+",");
            idBld.Append(product+",");
            idBld.Append(contract);

            String id = idBld.ToString();

            // Obtain the bid depth (Level based on user selection).
            Array dataArrayBid = (Array)pInstr.get_Get("BidDepth(0)#");

            // Test if depth exists.
            if (dataArrayBid != null)
            {
                // Iterate through the depth array.
                for (int i = 0; i <= dataArrayBid.GetUpperBound(0); i++)
                {
                    // Break out of FOR LOOP if index value is null.
                    if (dataArrayBid.GetValue(i,0) == null)
                        break;

                    String bidDepth = id+",B,"+dataArrayBid.GetValue(i,0);
                    //Console.WriteLine(bidDepth+":::"+dataArrayBid.GetValue(i,1));
                    depths.Add(bidDepth,dataArrayBid.GetValue(i,1));

                }
            }

            // Obtain the ask depth (Level based on user selection).
            Array dataArrayAsk = (Array) pInstr.get_Get("AskDepth(0)#");

            // Test if depth exists.
            if (dataArrayAsk != null)
            {
                // Iterate through the depth array.
                for (int i = 0; i <= dataArrayAsk.GetUpperBound(0); i++)
                {
                    // Break out of FOR LOOP if index value is null.
                    if (dataArrayAsk.GetValue(i,0) == null)
                        break;

                    String askDepth = id+",A,"+dataArrayAsk.GetValue(i,0);
                    //Console.WriteLine(askDepth+":::"+dataArrayAsk.GetValue(i,1));
                    depths.Add(askDepth,dataArrayAsk.GetValue(i,1));

                }
            }
        }
        /// <summary>
        /// Publish specific information about each order to the GUI
        /// </summary>
        /// <param name="pNewOrderObj">New order object</param>
        /// <param name="pOldOrderObj">Old order object</param>
        private void PublishEventOrderData(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj)
        {
            if (pOldOrderObj.IsNull != 0)
            {
                txtStatusOut.Text += "Old Order: NULL\r\n";
            }
            else
            {
                try
                {
                    Array oldOrderData = (Array)pOldOrderObj.get_Get("Contract$,BuySell,OrderQty,Price,OrderNo,ExecutionType");

                    txtStatusOut.Text += "Old Order: " + oldOrderData.GetValue(0).ToString() + ", " +
                                                         oldOrderData.GetValue(1).ToString() + ", " +
                                                         oldOrderData.GetValue(2).ToString() + ", " +
                                                         oldOrderData.GetValue(3).ToString() + ", " +
                                                         oldOrderData.GetValue(4).ToString() + ", " +
                                                         oldOrderData.GetValue(5).ToString() + "\r\n";
                }
                catch (Exception ex)
                {
                    txtStatusOut.Text += "Old Order: Error Message - " + ex.Message + "\r\n";
                }
            }

            if (pNewOrderObj.IsNull != 0)
            {
                txtStatusOut.Text += "New Order: NULL\r\n";
            }
            else
            {
                try
                {
                    Array newOrderData = (Array)pNewOrderObj.get_Get("Contract$,BuySell,OrderQty,Price,OrderNo,ExecutionType");

                    txtStatusOut.Text += "New Order: " + newOrderData.GetValue(0).ToString() + ", " +
                                                         newOrderData.GetValue(1).ToString() + ", " +
                                                         newOrderData.GetValue(2).ToString() + ", " +
                                                         newOrderData.GetValue(3).ToString() + ", " +
                                                         newOrderData.GetValue(4).ToString() + ", " +
                                                         newOrderData.GetValue(5).ToString() + "\r\n";
                }
                catch (Exception ex)
                {
                    txtStatusOut.Text += "New Order: Error Message - " + ex.Message + "\r\n";
                }
            }

            txtStatusOut.Text += "\r\n";
        }
        /// <summary>
        /// Triggered when the XTAPI receives an order rejection message from the exchange for an 
        /// order in the order set.
        /// </summary>
        /// <param name="pRejectedOrderObj">Order object for the rejected order</param>
        void m_TTOrderSet_OnOrderRejected(XTAPI.TTOrderObj pRejectedOrderObj)
        {
            string siteOrderKey = (string)pRejectedOrderObj.get_Get("SiteOrderKey");

            txtStatusOut.Text += "Order Rejected by Exchange: " + siteOrderKey + "\r\n\r\n";
        }
Exemple #13
0
        public void OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            try
            {
                //we use the same TTInstrNotify.OnNotifyFound event so we need to check the Product
                if( Convert.ToString(pInstr.get_Get("Product")) == instrument.Product )
                {
                    tickPrice = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "#"));
                    tickIncr = Convert.ToInt16(pInstr.get_Get("TickIncrement"));
                }

                if (OnFound != null)
                    OnFound(this, new FoundEventArgs(tickPrice));

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #14
0
        private void OnOrderFillData(XTAPI.TTFillObj pFill)
        {
            try
            {
                Fill fill = new Fill();

                Array data = (Array)pFill.get_Get("Key,FillType,BuySell,Qty,Price#,NetQty,Acct,Contract.Product");

                fill.Key = (string)data.GetValue(0);
                fill.Full = ((string)data.GetValue(1)).Equals("F");
                fill.Buy = ((string)data.GetValue(2)).Equals("B");
                fill.Qty = (int)data.GetValue(3);
                fill.Price = (double)data.GetValue(4);
                fill.NetQty = (int)data.GetValue(5);
                fill.Account = (string)data.GetValue(6);
                fill.Product = (string)data.GetValue(7);

                if (OnFill != null )
                {
                    OnFill(this, new FillEventArgs(fill));
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled) log.Error(ex.StackTrace);
            }
        }
        /// <summary>
        /// This function is called when an instrument is located after calling m_TTInstrObj.Open()
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Instrument Found.";

            // Retrieve the instrument information using the TTInstrObj Get Properties.
            //
            // Notes:
            //  1) The trailing pound sign (#) returns the decimal format for the requested attribute.
            //  2) The tilde (~) prefix returns the last change, or delta (delta = current - previous), in the attribute.
            Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract,Bid#,BidQty$,Ask$,AskQty$,Last$,LastQty$,~LastQty$");

            txtExchange.Text = (string)data.GetValue(0);
            txtProduct.Text = (string)data.GetValue(1);
            txtProductType.Text = (string)data.GetValue(2);
            txtContract.Text = (string)data.GetValue(3);

            // Use Convert methods rather than explicit casting if the expected variant data type is different than the cast.
            txtBidPrice.Text = Convert.ToString(data.GetValue(4));
            txtBidQty.Text = (string)data.GetValue(5);
            txtAskPrice.Text = (string)data.GetValue(6);
            txtAskQty.Text = (string)data.GetValue(7);
            txtLastPrice.Text = (string)data.GetValue(8);
            txtLastQty.Text = (string)data.GetValue(9);
            txtLastQtyDelta.Text = (string)data.GetValue(10);
        }
        /// <summary>
        /// This function is called for every fill update.  Obtain the fill 
        /// information by calling the Get() properties from the TTFillObj 
        /// passed as an argument.   
        /// </summary>
        /// <param name="pFillObj">XTAPI Fill Object</param>
        private void m_TTOrderSet_OnOrderFillData(XTAPI.TTFillObj pFillObj)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Fill Recieved.";

            // Retrieve the fill information using the TTFillObj Get Properties.
            Array fillData = (Array) pFillObj.get_Get("Contract,Price,Qty,FillType,OrderNo,SiteOrderKey");

            txtFillData.Text += (string)fillData.GetValue(0) + ",  ";
            txtFillData.Text += (string)fillData.GetValue(1) + ",  ";
            txtFillData.Text += Convert.ToString(fillData.GetValue(2)) + ",  ";
            txtFillData.Text += (string)fillData.GetValue(3) + ",  ";
            txtFillData.Text += (string)fillData.GetValue(4) + ",  ";
            txtFillData.Text += (string)fillData.GetValue(5) + "\r\n";
        }
        /// <summary>
        /// This function is called when an instrument update
        /// occurs (i.e. last traded price changes).
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Retrieve the instrument information using the TTInstrObj Get Properties.
            Array data = (Array) pInstr.get_Get("Bid#,BidQty$,Ask$,AskQty$,Last$,LastQty$,~LastQty$");

            txtBidPrice.Text = Convert.ToString(data.GetValue(0));
            txtBidQty.Text = (string)data.GetValue(1);
            txtAskPrice.Text = (string)data.GetValue(2);
            txtAskQty.Text = (string)data.GetValue(3);
            txtLastPrice.Text = (string)data.GetValue(4);
            txtLastQty.Text = (string)data.GetValue(5);
            txtLastQtyDelta.Text = (string)data.GetValue(6);
        }
        /// <summary>
        /// This function is called when an instrument is found after it is opened.
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Instrument Found.";

            // Retrieve and display the instrument information.
            Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract");

            // Test based on Alias property
            switch (pInstr.Alias)
            {
                case "0":
                    txtExchange1.Text = (string)data.GetValue(0);
                    txtProduct1.Text = (string)data.GetValue(1);
                    txtProductType1.Text = (string)data.GetValue(2);
                    txtContract1.Text = (string)data.GetValue(3);
                    break;
                case "1":
                    txtExchange2.Text = (string)data.GetValue(0);
                    txtProduct2.Text = (string)data.GetValue(1);
                    txtProductType2.Text = (string)data.GetValue(2);
                    txtContract2.Text = (string)data.GetValue(3);
                    break;
                case "2":
                    txtExchange3.Text = (string)data.GetValue(0);
                    txtProduct3.Text = (string)data.GetValue(1);
                    txtProductType3.Text = (string)data.GetValue(2);
                    txtContract3.Text = (string)data.GetValue(3);
                    break;
                case "3":
                    txtExchange4.Text = (string)data.GetValue(0);
                    txtProduct4.Text = (string)data.GetValue(1);
                    txtProductType4.Text = (string)data.GetValue(2);
                    txtContract4.Text = (string)data.GetValue(3);
                    break;
                default:
                    MessageBox.Show(this,"DisplayInstrumentInformation ERROR");
                    break;
            }
        }
        /// <summary>
        /// This function is called when an instrument is found after it is opened.
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Instrument Found.";

            // Retrieve the instrument information using the TTInstrObj Get Properties.
            // The use of a tilde before the property name will return the delta (current - previous).
            Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract");

            txtExchange.Text = (string)data.GetValue(0);
            txtProduct.Text = (string)data.GetValue(1);
            txtProductType.Text = (string)data.GetValue(2);
            txtContract.Text = (string)data.GetValue(3);
        }
        /// <summary>
        /// This function is called when an instrument is located after calling m_TTInstrObj.Open()
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Instrument Found.";

            // Retrieve the instrument information using the TTInstrObj Get Properties.
            Array data = (Array)pInstr.get_Get("Exchange,Product,ProdType,Contract");

            txtMFoundExchange.Text = (string)data.GetValue(0);
            txtMFoundProduct.Text = (string)data.GetValue(1);
            txtMFoundProdType.Text = (string)data.GetValue(2);
            txtMFoundContract.Text = (string)data.GetValue(3);

            // Enable the other parts of the "Publish" section for publishing SODs
            txtPublishPrice.Enabled = true;
            txtPublishQty.Enabled = true;
            cboMPublishPriceFormat.Enabled = true;
            btnCreateManualFill.Enabled = true;
            optBuy.Enabled = true;
            optSell.Enabled = true;
        }
        /// <summary>
        /// This function is called when an instrument is located after calling m_TTInstrObj.Open()
        /// </summary>
        /// <param name="pNotify">TTInstrNotify object</param>
        /// <param name="pInstr">TTInstrObj object</param>
        private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            // Update the Status Bar text.
            sbaStatus.Text = "Instrument Found.";

            // Retrieve the instrument information using the TTInstrObj Get Properties.
            //
            // Notes:
            //  1) The tilde (~) prefix returns the last change, or delta (delta = current - previous), in the attribute.
            Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract,Bid$,BidQty$,Ask$,AskQty$,Last$,LastQty$,~LastQty$");

            txtExchange.Text = (string)data.GetValue(0);
            txtProduct.Text = (string)data.GetValue(1);
            txtProductType.Text = (string)data.GetValue(2);
            txtContract.Text = (string)data.GetValue(3);

            txtBidPrice.Text = (string)data.GetValue(4);
            txtBidQty.Text = (string)data.GetValue(5);
            txtAskPrice.Text = (string)data.GetValue(6);
            txtAskQty.Text = (string)data.GetValue(7);
            txtLastPrice.Text = (string)data.GetValue(8);
            txtLastQty.Text = (string)data.GetValue(9);
            txtLastQtyDelta.Text = (string)data.GetValue(10);
        }