Ejemplo n.º 1
0
        /// <summary>
        /// This function sets up the OrderProfile and submits
        /// the order using the InstrumentTradeSubscription SendOrder method.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(BuySell buySell)
        {
            try
            {
                OrderFeed            orderFeed = comboBoxOrderFeed.SelectedItem as OrderFeed;
                CustomerDefaultEntry customer  = cboCustomer.SelectedItem as CustomerDefaultEntry;

                OrderProfile orderProfile = new OrderProfile(orderFeed, m_instrumentTradeSubscription.Instrument, customer.Customer);

                // Set for Buy or Sell.
                orderProfile.BuySell = buySell;

                // Set the quantity.
                orderProfile.QuantityToWork = Quantity.FromString(m_instrumentTradeSubscription.Instrument, txtQuantity.Text);

                // Set the order type to "Limit" for a limit order.
                orderProfile.OrderType = OrderType.Limit;
                // Set the limit order price.
                orderProfile.LimitPrice = Price.FromString(m_instrumentTradeSubscription.Instrument, txtPrice.Text);

                // Send the order.
                m_instrumentTradeSubscription.SendOrder(orderProfile);

                m_LastOrderSiteOrderKey = orderProfile.SiteOrderKey;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This function sets up the OrderProfile and submits
        /// the order using the InstrumentTradeSubscription SendOrder method.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(TTInstrument ttinstr, ZOrder o)
        {
            var orderSide    = o.Side;
            var qtyStr       = o.Qty.ToString();
            var priceStr     = o.Price.ToString();
            var orderType    = o.Type;
            var stopPriceStr = o.StopPrice.ToString();                 // TODO: WE NEED TO DEAL WITH STOP ORDERS!!!

            cout("TeTTApi::SendOrder: {0}", o.ToString());
            try
            {
                CustomerDefaultEntry m_defaultCustomer = null;
                OrderProfile         orderProfile      = new OrderProfile(ttinstr.DefaultOrderFeed, ttinstr.Instrument, m_defaultCustomer.Customer);

                orderProfile.BuySell        = TranslateSide(orderSide);                        // Set for Buy or Sell.
                orderProfile.QuantityToWork = Quantity.FromString(ttinstr.Instrument, qtyStr); // Set the quantity.

                if (orderType == ZOrderType.Market)                                            // Market Order
                {
                    orderProfile.OrderType = OrderType.Market;
                }
                else if (orderType == ZOrderType.Limit)     // Limit Order
                {
                    // Set the limit order price.
                    orderProfile.LimitPrice = Price.FromString(ttinstr.Instrument, priceStr);
                }
                else if (orderType == ZOrderType.StopMarket)                                      // Stop Market Order
                {
                    orderProfile.OrderType = OrderType.Market;                                    // Set the order type to "Market" for a market order.
                    orderProfile.Modifiers = OrderModifiers.Stop;                                 // Set the order modifiers to "Stop" for a stop order.
                    orderProfile.StopPrice = Price.FromString(ttinstr.Instrument, stopPriceStr);  // Set the stop price.
                }
                else if (orderType == ZOrderType.StopLimit)                                       // Stop Limit Order
                {
                    orderProfile.OrderType  = OrderType.Limit;                                    // Set the order type to "Limit" for a limit order.
                    orderProfile.Modifiers  = OrderModifiers.Stop;                                // Set the order modifiers to "Stop" for a stop order.
                    orderProfile.LimitPrice = Price.FromString(ttinstr.Instrument, priceStr);     // Set the limit order price.
                    orderProfile.StopPrice  = Price.FromString(ttinstr.Instrument, stopPriceStr); // Set the stop price.
                }

                //m_instrumentTradeSubscription.SendOrder(orderProfile);  // Send the order.

                cout("TT Order Send {0} {1}|{2}@{3}", orderProfile.SiteOrderKey, orderProfile.BuySell.ToString(), orderProfile.QuantityToWork.ToString(), LimitOrMarketPrice(orderProfile));

                /*// Update the GUI.
                 * txtOrderBook.Text += String.Format("Send {0} {1}|{2}@{3}{4}",
                 *  orderProfile.SiteOrderKey,
                 *  orderProfile.BuySell.ToString(),
                 *  orderProfile.QuantityToWork.ToString(),
                 *  orderProfile.OrderType == OrderType.Limit ? orderProfile.LimitPrice.ToString() : "Market Price",
                 *  System.Environment.NewLine);*/
            }
            catch (Exception err)
            {
                ErrorMessage(err.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This function sets up the OrderProfile and submits
        /// the order using the InstrumentTradeSubscription SendOrder method.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(BuySell buySell)
        {
            // make sure the user has dragged a contract before we continue
            if (m_instrumentTradeSubscription == null)
            {
                return;
            }

            try
            {
                OrderFeed            orderFeed = this.cboOrderFeed.SelectedItem as OrderFeed;
                CustomerDefaultEntry customer  = this.cboCustomer.SelectedItem as CustomerDefaultEntry;

                OrderProfile orderProfile = new OrderProfile(orderFeed, m_instrumentTradeSubscription.Instrument, customer.Customer);

                // Set for Buy or Sell.
                orderProfile.BuySell = buySell;

                // Set the quantity.
                orderProfile.QuantityToWork = Quantity.FromString(m_instrumentTradeSubscription.Instrument, txtQuantity.Text);

                // Set the order type to "Limit" for a limit order.
                orderProfile.OrderType = OrderType.Limit;

                // Set the limit order price.
                orderProfile.LimitPrice = Price.FromString(m_instrumentTradeSubscription.Instrument, txtPrice.Text);

                // Send the order.
                if (m_instrumentTradeSubscription.SendOrder(orderProfile))
                {
                    // log the order send
                    Console.WriteLine("Order Sent");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
        /// <summary>
        /// This function sets up the OrderProfile and submits
        /// the order using the InstrumentTradeSubscription SendOrder method.
        /// </summary>
        /// <param name="buySell">The side of the market to place the order on.</param>
        private void SendOrder(BuySell buySell)
        {
            try
            {
                OrderFeed            orderFeed = comboBoxOrderFeed.SelectedItem as OrderFeed;
                CustomerDefaultEntry customer  = cboCustomer.SelectedItem as CustomerDefaultEntry;

                OrderProfile orderProfile = new OrderProfile(orderFeed, m_instrumentTradeSubscription.Instrument, customer.Customer);

                // Set for Buy or Sell.
                orderProfile.BuySell = buySell;

                // Set the quantity.
                orderProfile.QuantityToWork = Quantity.FromString(m_instrumentTradeSubscription.Instrument, txtQuantity.Text);

                // Determine which Order Type is selected.
                if (cboOrderType.SelectedIndex == 0)  // Market Order
                {
                    // Set the order type to "Market" for a market order.
                    orderProfile.OrderType = OrderType.Market;
                }
                else if (cboOrderType.SelectedIndex == 1)  // Limit Order
                {
                    // Set the order type to "Limit" for a limit order.
                    orderProfile.OrderType = OrderType.Limit;
                    // Set the limit order price.
                    orderProfile.LimitPrice = Price.FromString(m_instrumentTradeSubscription.Instrument, txtPrice.Text);
                }
                else if (cboOrderType.SelectedIndex == 2)  // Stop Market Order
                {
                    // Set the order type to "Market" for a market order.
                    orderProfile.OrderType = OrderType.Market;
                    // Set the order modifiers to "Stop" for a stop order.
                    orderProfile.Modifiers = OrderModifiers.Stop;
                    // Set the stop price.
                    orderProfile.StopPrice = Price.FromString(m_instrumentTradeSubscription.Instrument, txtStopPrice.Text);
                }
                else if (cboOrderType.SelectedIndex == 3)  // Stop Limit Order
                {
                    // Set the order type to "Limit" for a limit order.
                    orderProfile.OrderType = OrderType.Limit;
                    // Set the order modifiers to "Stop" for a stop order.
                    orderProfile.Modifiers = OrderModifiers.Stop;
                    // Set the limit order price.
                    orderProfile.LimitPrice = Price.FromString(m_instrumentTradeSubscription.Instrument, txtPrice.Text);
                    // Set the stop price.
                    orderProfile.StopPrice = Price.FromString(m_instrumentTradeSubscription.Instrument, txtStopPrice.Text);
                }

                // Send the order.
                m_instrumentTradeSubscription.SendOrder(orderProfile);

                // Update the GUI.
                txtOrderBook.Text += String.Format("Send {0} {1}|{2}@{3}{4}",
                                                   orderProfile.SiteOrderKey,
                                                   orderProfile.BuySell.ToString(),
                                                   orderProfile.QuantityToWork.ToString(),
                                                   orderProfile.OrderType == OrderType.Limit ? orderProfile.LimitPrice.ToString() : "Market Price",
                                                   System.Environment.NewLine);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }