Esempio 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(TTInstrument ttinstr, ZS.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!!!

            try
            {
                TT.OrderProfile orderProfile = new TT.OrderProfile(ttinstr.DefaultOrderFeed, ttinstr.Instrument, m_defaultCustomer.Customer);

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

                if (orderType == ZS.ZOrderType.Market)                                            // Market Order
                {
                    orderProfile.OrderType = TT.OrderType.Market;
                }
                else if (orderType == ZS.ZOrderType.Limit)     // Limit Order
                {
                    // Set the limit order price.
                    orderProfile.LimitPrice = TT.Price.FromString(ttinstr.Instrument, priceStr);
                }
                else if (orderType == ZS.ZOrderType.StopMarket)                                      // Stop Market Order
                {
                    orderProfile.OrderType = TT.OrderType.Market;                                    // Set the order type to "Market" for a market order.
                    orderProfile.Modifiers = TT.OrderModifiers.Stop;                                 // Set the order modifiers to "Stop" for a stop order.
                    orderProfile.StopPrice = TT.Price.FromString(ttinstr.Instrument, stopPriceStr);  // Set the stop price.
                }
                else if (orderType == ZS.ZOrderType.StopLimit)                                       // Stop Limit Order
                {
                    orderProfile.OrderType  = TT.OrderType.Limit;                                    // Set the order type to "Limit" for a limit order.
                    orderProfile.Modifiers  = TT.OrderModifiers.Stop;                                // Set the order modifiers to "Stop" for a stop order.
                    orderProfile.LimitPrice = TT.Price.FromString(ttinstr.Instrument, priceStr);     // Set the limit order price.
                    orderProfile.StopPrice  = TT.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);
            }
        }
Esempio n. 2
0
 private string LimitOrMarketPrice(TT.OrderProfile orderProfile)
 {
     return(orderProfile.OrderType == TT.OrderType.Limit ? orderProfile.LimitPrice.ToString() : "Market Price");
 }