Ejemplo n.º 1
0
        public string SendOrder(string buySell, double price, InstrumentProc instrument)
        {
            XTAPI.TTOrderProfileClass TTOrderProfile = new XTAPI.TTOrderProfileClass();

            TTOrderProfile.Instrument = instrument.ttInstrObj;

            TTOrderProfile.Customer = "<Default>";

            TTOrderProfile.Set("Acct", instrument.Account);
            TTOrderProfile.Set("AcctType", "M1");
            TTOrderProfile.Set("BuySell", buySell);
            TTOrderProfile.Set("Qty", Convert.ToString(instrument.Size));
            TTOrderProfile.Set("OrderType", "L");
            TTOrderProfile.Set("Limit#", Convert.ToString(price));
            TTOrderProfile.Set("FFT2", "M");
            TTOrderProfile.Set("FFT3", "AutoMarket");

            try
            {
                int submittedQuantity = instrument.ttOrderSet.get_SendOrder(TTOrderProfile);
            }
            catch (Exception ex) {
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.StackTrace);
                }
            }

            return(Convert.ToString(TTOrderProfile.get_GetLast("SiteOrderKey")));
        }
Ejemplo n.º 2
0
        public string SendOrder(string buySell, double price, InstrumentProc instrument)
        {
            XTAPI.TTOrderProfileClass TTOrderProfile = new XTAPI.TTOrderProfileClass();

            TTOrderProfile.Instrument = instrument.ttInstrObj;

            TTOrderProfile.Customer = "<Default>";

            TTOrderProfile.Set("Acct", instrument.Account);
            TTOrderProfile.Set("AcctType", "M1");
            TTOrderProfile.Set("BuySell", buySell);
            TTOrderProfile.Set("Qty", Convert.ToString(instrument.Size));
            TTOrderProfile.Set("OrderType", "L");
            TTOrderProfile.Set("Limit#", Convert.ToString(price));
            TTOrderProfile.Set("FFT2", "M");
            TTOrderProfile.Set("FFT3", "AutoMarket");

            try
            {
                int submittedQuantity = instrument.ttOrderSet.get_SendOrder(TTOrderProfile);
            }
            catch (Exception ex) {
                if (log.IsErrorEnabled) log.Error(ex.StackTrace);
            }

            return (Convert.ToString(TTOrderProfile.get_GetLast("SiteOrderKey")));
        }
        /// <summary>
        /// This function sets up the TTOrderProfile and submits the order using the 
        /// TTOrderSet SendOrder method.  The SiteOrderKey from the order submission
        /// is saved internally and pushed to the UI.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(string buySell)
        {
            try
            {
                XTAPI.TTOrderProfileClass orderProfile = new XTAPI.TTOrderProfileClass();

                // Set the TTInstrObj to the TTOrderProfile.
                orderProfile.Instrument = m_TTInstrObj;
                // Set the customer default property (e.g. "<Default>").
                orderProfile.Customer = cboCustomer.SelectedItem.ToString();
                // Set for Buy or Sell.
                orderProfile.Set("BuySell", buySell);
                // Set the quantity.
                orderProfile.Set("Qty", txtQuantity.Text.ToString());
                // Set the order type to "L" for a limit order.
                orderProfile.Set("OrderType", "L");
                // Set the limit order price.
                orderProfile.Set("Limit$", txtPrice.Text.ToString());

                // Send the order by submitting the TTOrderProfile through the TTOrderSet.
                int submittedQuantity = m_TTOrderSet.get_SendOrder(orderProfile);

                // Obtain the SiteOrderKey for the last order submitted.
                m_LastOrderSiteOrderKey = (string)orderProfile.get_GetLast("SiteOrderKey");

                // Print the SiteOrderKey to the user interface.
                txtSiteOrderKey.Text = m_LastOrderSiteOrderKey;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
        }
        /// <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;
        }
        /// <summary>
        /// This function sets up the TTOrderProfile and submits the order using the 
        /// TTOrderSet SendOrder method.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(string buySell)
        {
            // Set the TTInstrObj to the TTOrderProfile.
            XTAPI.TTOrderProfileClass orderProfile = new XTAPI.TTOrderProfileClass();
            orderProfile.Instrument = m_TTInstrObj;

            try
            {
                // Set the customer default property (e.g. "<Default>").
                orderProfile.Customer = cboCustomer.SelectedItem.ToString();

                // Set for Buy or Sell.
                orderProfile.Set("BuySell",buySell);

                // Set the quantity.
                orderProfile.Set("Qty",txtQuantity.Text.ToString());

                // Determine which Order Type is selected.
                if( cboOrderType.SelectedIndex == 0 )  // Market Order
                {
                    // Set the order type to "M" for a market order.
                    orderProfile.Set("OrderType","M");
                }
                else if( cboOrderType.SelectedIndex == 1 )  // Limit Order
                {
                    // Set the order type to "L" for a limit order.
                    orderProfile.Set("OrderType","L");
                    // Set the limit order price.
                    orderProfile.Set("Limit$",txtPrice.Text.ToString());
                }
                else if( cboOrderType.SelectedIndex == 2 )  // Stop Market Order
                {
                    // Set the order type to "M" for a market order.
                    orderProfile.Set("OrderType","M");
                    // Set the order restriction to "S" for a stop order.
                    orderProfile.Set("OrderRestr","S");
                    // Set the stop price.
                    orderProfile.Set("Stop$",txtStopPrice.Text.ToString());
                }
                else if( cboOrderType.SelectedIndex == 3 )  // Stop Limit Order
                {
                    // Set the order type to "L" for a limit order.
                    orderProfile.Set("OrderType","L");
                    // Set the order restriction to "S" for a stop order.
                    orderProfile.Set("OrderRestr","S");
                    // Set the limit price.
                    orderProfile.Set("Limit$",txtPrice.Text.ToString());
                    // Set the stop price.
                    orderProfile.Set("Stop$",txtStopPrice.Text.ToString());
                }

                // Send the order by submitting the TTOrderProfile through the TTOrderSet.
                int submittedQty = m_TTOrderSet.get_SendOrder(orderProfile);

                // Display the submitted quantity in the user interface.
                txtOrderBook.Text += "Quantity Sent: " + submittedQty.ToString() + "\r\n";
            }
            catch (Exception ex)
            {
                // Display exception message.
                MessageBox.Show(ex.Message, "Exception");
            }
        }
        /// <summary>
        /// This function sets up the TTOrderProfile and submits the order using the 
        /// TTOrderSet SendOrder method.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(string buySell)
        {
            try
            {
                XTAPI.TTOrderProfileClass orderProfile = new XTAPI.TTOrderProfileClass();

                // Set the TTInstrObj to the TTOrderProfile.
                orderProfile.Instrument = m_TTInstrObj;
                // Set the customer default property (e.g. "<Default>").
                orderProfile.Customer = cboCustomer.SelectedItem.ToString();
                // Set for Buy or Sell.
                orderProfile.Set("BuySell", buySell);
                // Set the quantity.
                orderProfile.Set("Qty", txtQuantity.Text);
                // Set the order type to "L" for a limit order.
                orderProfile.Set("OrderType", "L");
                // Set the limit order price.
                orderProfile.Set("Limit$", txtPrice.Text);

                // Send the order by submitting the TTOrderProfile through the TTOrderSet.
                int submittedQuantity = m_TTOrderSet.get_SendOrder(orderProfile);
            }
            catch (Exception ex)
            {
                // Display exception message.
                MessageBox.Show(ex.Message, "Exception");
            }
        }