/// <summary>
        /// Dispose of all the TT API objects and shutdown the TT API
        /// </summary>
        public void shutdownTTAPI()
        {
            if (!m_shutdownInProcess)
            {
                // Dispose of all request objects
                if (m_customerDefaultsSubscription != null)
                {
                    m_customerDefaultsSubscription.CustomerDefaultsChanged -= m_customerDefaultsSubscription_CustomerDefaultsChanged;
                    m_customerDefaultsSubscription.Dispose();
                    m_customerDefaultsSubscription = null;
                }

                if (m_instrumentTradeSubscription != null)
                {
                    m_instrumentTradeSubscription.OrderAdded    -= m_instrumentTradeSubscription_OrderAdded;
                    m_instrumentTradeSubscription.OrderRejected -= m_instrumentTradeSubscription_OrderRejected;
                    m_instrumentTradeSubscription.Dispose();
                    m_instrumentTradeSubscription = null;
                }

                if (m_priceSubscription != null)
                {
                    m_priceSubscription.FieldsUpdated -= m_priceSubscription_FieldsUpdated;
                    m_priceSubscription.Dispose();
                    m_priceSubscription = null;
                }

                TTAPI.ShutdownCompleted += new EventHandler(TTAPI_ShutdownCompleted);
                TTAPI.Shutdown();
            }

            // only run shutdown once
            m_shutdownInProcess = true;
        }
Example #2
0
        /// <summary>
        /// Event notification for CustomerDefaultsChanged subscription
        /// </summary>
        void m_cd_CustomerDefaultsChanged(object sender, EventArgs e)
        {
            m_lcd.Clear();

            CustomerDefaultsSubscription cds = sender as CustomerDefaultsSubscription;

            foreach (CustomerDefaultEntry entry in cds.CustomerDefaults)
            {
                m_lcd.Add(entry);
            }
        }
Example #3
0
        /// <summary>
        /// CustomerDefaultsChanged subscription callback.
        /// Update the customers List (and select first list item as DefaultCustomer, if any list items exist).
        /// </summary>
        void m_customerDefaultsSubscription_CustomerDefaultsChanged(object sender, EventArgs e)
        {
            customers.Clear();
            CustomerDefaultsSubscription cds = sender as CustomerDefaultsSubscription;

            foreach (CustomerDefaultEntry entry in cds.CustomerDefaults)
            {
                customers.Add(entry);
            }
            m_defaultCustomer = (customers.Count > 0 ? customers[0] : null);
        }
        /// <summary>
        /// ConnectionStatusUpdate callback.
        /// Give feedback to the user that there was an issue starting up and connecting to XT.
        /// </summary>
        void ttapiInstance_ConnectionStatusUpdate(object sender, ConnectionStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                this.Enabled = true;

                m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, Dispatcher.Current);
                m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_CustomerDefaultsSubscription_CustomerDefaultsChanged);
                m_customerDefaultsSubscription.Start();
            }
            else
            {
                MessageBox.Show(String.Format("ConnectionStatusUpdate: {0}", e.Status.StatusMessage));
            }
        }
Example #5
0
        /// <summary>
        /// ConnectionStatusUpdate callback.
        /// Give feedback to the user that there was an issue starting up and connecting to XT.
        /// </summary>
        void ttapiInstance_ConnectionStatusUpdate(object sender, ConnectionStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                this.Enabled = true;

                m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, Dispatcher.Current);
                m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_CustomerDefaultsSubscription_CustomerDefaultsChanged);
                m_customerDefaultsSubscription.Start();
            }
            else
            {
                MessageBox.Show(String.Format("ConnectionStatusUpdate: {0}", e.Status.StatusMessage));
            }
        }
        /// <summary>
        /// Init and start TT API.
        /// </summary>
        /// <param name="instance">XTraderModeTTAPI instance</param>
        /// <param name="ex">Any exception generated from the ApiCreationException</param>
        public void ttApiInitHandler(TTAPI api, ApiCreationException ex)
        {
            if (ex == null)
            {
                m_TTAPI = (XTraderModeTTAPI)api;
                m_TTAPI.ConnectionStatusUpdate += new EventHandler <ConnectionStatusUpdateEventArgs>(ttapiInstance_ConnectionStatusUpdate);
                m_TTAPI.Start();

                m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, Dispatcher.Current);
                m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_customerDefaultsSubscription_CustomerDefaultsChanged);
                m_customerDefaultsSubscription.Start();
            }
            else if (!ex.IsRecoverable)
            {
                MessageBox.Show("API Initialization Failed: " + ex.Message);
            }
        }
        /// <summary>
        /// Init and start TT API.
        /// </summary>
        /// <param name="instance">XTraderModeTTAPI instance</param>
        /// <param name="ex">Any exception generated from the ApiCreationException</param>
        public void ttApiInitHandler(TTAPI api, ApiCreationException ex)
        {
            if (ex == null)
            {
                m_TTAPI = (XTraderModeTTAPI)api;
                m_TTAPI.ConnectionStatusUpdate += new EventHandler<ConnectionStatusUpdateEventArgs>(ttapiInstance_ConnectionStatusUpdate);
                m_TTAPI.Start();

                m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, Dispatcher.Current);
                m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_customerDefaultsSubscription_CustomerDefaultsChanged);
                m_customerDefaultsSubscription.Start();
            }
            else if (!ex.IsRecoverable)
            {
                MessageBox.Show("API Initialization Failed: " + ex.Message);
            }
        }
Example #8
0
 /// <summary>
 /// Init and start TT API.
 /// </summary>
 /// <param name="instance">XTraderModeTTAPI instance</param>
 /// <param name="ex">Any exception generated from the ApiCreationException</param>
 public void ttApiInitHandler(TT.TTAPI api, TT.ApiCreationException ex)
 {
     if (ex == null)
     {
         m_TTAPI = (TT.XTraderModeTTAPI)api;
         m_TTAPI.ConnectionStatusUpdate += new EventHandler <TT.ConnectionStatusUpdateEventArgs>(ttapiInstance_ConnectionStatusUpdate);
         m_TTAPI.Start();
         m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, TT.Dispatcher.Current);
         m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_customerDefaultsSubscription_CustomerDefaultsChanged);
         m_customerDefaultsSubscription.Start();
     }
     else if (ex.IsRecoverable)
     {
         cout("TTAPI Initialization: {0}", ex.Message);
     }
     else
     {
         ErrorMessage("TTAPI Initialization Failed: {0}", ex.Message);
     }
 }
Example #9
0
        /// <summary>
        /// Event notification for status of TT API initialization
        /// </summary>
        public void ttApiInitComplete(TTAPI api, ApiCreationException ex)
        {
            cout("TengineTT: TTAPI initialization complete");
            if (ex == null)
            {
                // Authenticate your credentials
                m_TTAPI = (UniversalLoginTTAPI)api;
                m_TTAPI.AuthenticationStatusUpdate += new EventHandler <AuthenticationStatusUpdateEventArgs>(apiInstance_AuthenticationStatusUpdate);    // for UniversalLoginTTAPI
                //m_TTAPI.ConnectionStatusUpdate += new EventHandler<ConnectionStatusUpdateEventArgs>(ttapiInstance_ConnectionStatusUpdate);              // for XTraderModeTTAPI
                m_TTAPI.Start();

                m_cdSub = new CustomerDefaultsSubscription(m_TTAPI.Session, Dispatcher.Current);
                m_cdSub.CustomerDefaultsChanged += new EventHandler(m_cd_CustomerDefaultsChanged);
                m_cdSub.Start();
            }
            else
            {
                cout("TengineTT: TTAPI Initialization Failed: {0}", ex.Message);
                Dispose();
            }
        }
Example #10
0
        /// <summary>
        /// CustomerDefaultsChanged subscription callback.
        /// Update the Customer combo box.
        /// </summary>
        void m_CustomerDefaultsSubscription_CustomerDefaultsChanged(object sender, EventArgs e)
        {
            try
            {
                this.cboCustomer.Items.Clear();
                CustomerDefaultsSubscription cds = sender as CustomerDefaultsSubscription;
                foreach (CustomerDefaultEntry entry in cds.CustomerDefaults)
                {
                    this.cboCustomer.Items.Add(entry);
                }

                if (this.cboCustomer.Items.Count > 0)
                {
                    this.cboCustomer.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
        }
Example #11
0
        /// <summary>
        /// Shuts down the TT API
        /// </summary>
        public void Dispose()
        {
            lock (m_lock)
            {
                if (!m_disposed)
                {
                    // Dispose of all request objects
                    if (m_cdSub != null)
                    {
                        m_cdSub.CustomerDefaultsChanged -= m_cd_CustomerDefaultsChanged;
                        m_cdSub.Dispose();
                        m_cdSub = null;
                    }

                    // TODO: DISPOSE OF ALL TT OBJECTS HERE!

                    /*if (m_instrumentTradeSubscription != null)
                     * {
                     *  m_instrumentTradeSubscription.OrderAdded -= m_instrumentTradeSubscription_OrderAdded;
                     *  m_instrumentTradeSubscription.OrderRejected -= m_instrumentTradeSubscription_OrderRejected;
                     *  m_instrumentTradeSubscription.Dispose();
                     *  m_instrumentTradeSubscription = null;
                     * }
                     *
                     * if (m_priceSubscription != null)
                     * {
                     *  m_priceSubscription.FieldsUpdated -= m_priceSubscription_FieldsUpdated;
                     *  m_priceSubscription.Dispose();
                     *  m_priceSubscription = null;
                     * }*/

                    // Begin shutdown the TT API
                    TTAPI.ShutdownCompleted += new EventHandler(TTAPI_ShutdownCompleted);
                    TTAPI.Shutdown();

                    m_disposed = true;
                }
            }
        }
        /// <summary>
        /// Dispose of all the TT API objects and shutdown the TT API 
        /// </summary>
        public void shutdownTTAPI()
        {
            if (!m_shutdownInProcess)
            {
                // Dispose of all request objects
                if (m_customerDefaultsSubscription != null)
                {
                    m_customerDefaultsSubscription.CustomerDefaultsChanged -= m_CustomerDefaultsSubscription_CustomerDefaultsChanged;
                    m_customerDefaultsSubscription.Dispose();
                    m_customerDefaultsSubscription = null;
                }

                if (m_instrumentTradeSubscription != null)
                {
                    m_instrumentTradeSubscription.OrderAdded -= instrumentTradeSubscription_OrderAdded;
                    m_instrumentTradeSubscription.OrderDeleted -= instrumentTradeSubscription_OrderDeleted;
                    m_instrumentTradeSubscription.Dispose();
                    m_instrumentTradeSubscription = null;
                }

                TTAPI.ShutdownCompleted += new EventHandler(TTAPI_ShutdownCompleted);
                TTAPI.Shutdown();
            }

            // only run shutdown once
            m_shutdownInProcess = true;
        }
        /// <summary>
        /// Init and start TT API.
        /// Create a customer defaults scbscription.
        /// </summary>
        public void initTTAPI(XTraderModeTTAPI apiInstance, Exception ex)
        {
            m_TTAPI = apiInstance;
            m_TTAPI.ConnectionStatusUpdate += new EventHandler<ConnectionStatusUpdateEventArgs>(m_TTAPI_ConnectionStatusUpdate);
            m_TTAPI.ConnectToXTrader();

            m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, m_dispatcher);
            m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_customerDefaultsSubscription_CustomerDefaultsChanged);
            m_customerDefaultsSubscription.Start();
        }
        /// <summary>
        /// ConnectionStatusUpdate
        /// Enable the form when successfully connected to X_Trader.
        /// If an error occurs display it in the status bar.
        /// </summary>
        void m_TTAPI_ConnectionStatusUpdate(object sender, ConnectionStatusUpdateEventArgs e)
        {
            if (e.Status.IsSuccess)
            {
                m_customerDefaultsSubscription = new CustomerDefaultsSubscription(m_TTAPI.Session, m_dispatcher);
                m_customerDefaultsSubscription.CustomerDefaultsChanged += new EventHandler(m_customerDefaultsSubscription_CustomerDefaultsChanged);
                m_customerDefaultsSubscription.Start();

                Enabled = true;
                UpdateStatusBar("Drag and Drop an instrument from the Market Grid in X_TRADER to this window.");
            }
            else
            {
                UpdateStatusBar(String.Format("ConnectionStatusUpdate: {0}", e.Status.StatusMessage));
            }
        }