Exemple #1
0
        }//SetConfirmMode()

        //
        #endregion//Private Methods


        #region Event Handlers
        // *****************************************************************
        // ****                     Event Handlers                     ****
        // *****************************************************************
        //
        //
        private void buttonSubmitFill_Click(object sender, EventArgs e)
        {
            if (m_IsConfirmMode)
            {   // The user has confirmed to send this.
                // Read numbers again
                bool isGoodToSendOrder = true;
                int  qty = 0;
                if (!Int32.TryParse(textBoxQty.Text, out qty))
                {
                    isGoodToSendOrder = false;
                }
                double price = 0;
                if (!Double.TryParse(textBoxPrice.Text, out price))
                {
                    isGoodToSendOrder = false;
                }

                if (isGoodToSendOrder)
                {
                    // Submit fill now
                    UV.Lib.OrderHubs.Fill aFill = UV.Lib.OrderHubs.Fill.Create();
                    aFill.Price     = price;
                    aFill.Qty       = qty;
                    aFill.LocalTime = Log.GetTime();


                    /*
                     * //UV.Lib.Products.InstrumentBase instrBase = null;
                     * TradingTechnologies.TTAPI.InstrumentDetails details;
                     * if (m_CurrentInstrument != m_EmptyInstrument && m_Market.TryGetInstrumentDetails(m_CurrentInstrument, out details) && details != null && details.Key != null)
                     * {   // TODO: Somewhere around here a null exception was thrown.
                     *  if ( Log != null)
                     *      Log.NewEntry(UV.Lib.Hubs.LogLevel.Major, "FormAddFills.SubmitFill_Click: Submitting fill request {0} or ForeignKey is null", m_CurrentInstrument);
                     *  TradingTechnologies.TTAPI.InstrumentKey instrKey = (TradingTechnologies.TTAPI.InstrumentKey)details.Key;
                     *  Ambre.TTServices.Fills.FillEventArgs fillEventArgs = new Ambre.TTServices.Fills.FillEventArgs(instrKey, Ambre.TTServices.Fills.FillType.UserAdjustment, aFill);
                     *  m_FillHub.HubEventEnqueue(fillEventArgs);
                     * }
                     * else if (Log != null)
                     *  Log.NewEntry(UV.Lib.Hubs.LogLevel.Warning, "FormAddFills.SubmitFill_Click: Failed {0} or ForeignKey is null", m_CurrentInstrument);
                     */
                    TradingTechnologies.TTAPI.InstrumentKey instrumentKey;
                    if (m_CurrentInstrument != m_EmptyInstrument && m_FillHub.TryGetInstrumentKey(m_CurrentInstrument, out instrumentKey))
                    {   // TODO: Somewhere around here a null exception was thrown.
                        if (Log != null)
                        {
                            Log.NewEntry(UV.Lib.Hubs.LogLevel.Major, "FormAddFills.SubmitFill_Click: Submitting fill request {0}.", m_CurrentInstrument);
                        }
                        UV.TTServices.Fills.FillEventArgs fillEventArgs = new UV.TTServices.Fills.FillEventArgs(instrumentKey, UV.TTServices.Fills.FillType.UserAdjustment, aFill);
                        m_FillHub.HubEventEnqueue(fillEventArgs);
                    }
                    else if (Log != null)
                    {
                        Log.NewEntry(UV.Lib.Hubs.LogLevel.Warning, "FormAddFills.SubmitFill_Click: Failed {0} or ForeignKey is null", m_CurrentInstrument);
                    }


                    // REset the colors
                    textBoxQty.Text = string.Empty;                         // protection against user's adding fill twice.
                    SetConfirmMode(buttonSubmitFill, false, 0);             // reset colors and text on button
                }
            }
            else
            {
                bool isGood = true;
                int  qty    = 0;
                if (Int32.TryParse(textBoxQty.Text, out qty))
                {
                    textBoxQty.Text = string.Format("{0:+0;-0;0}", qty);
                }
                else
                {
                    textBoxQty.Text = "0";
                    isGood          = false;
                }
                double price = 0;
                if (Double.TryParse(textBoxPrice.Text, out price))
                {
                    textBoxPrice.Text = string.Format("{0}", price);
                }
                else
                {
                    textBoxPrice.Text = "";
                    isGood            = false;
                }
                // Set
                SetConfirmMode(buttonSubmitFill, isGood, qty);                            // set colors to "confirm" mode.
            }
        }