Example #1
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(TTAPI api, ApiCreationException ex)
 {
     if (ex == null)
     {
         m_TTAPI = (XTraderModeTTAPI)api;
         m_TTAPI.ConnectionStatusUpdate += new EventHandler <ConnectionStatusUpdateEventArgs>(ttapiInstance_ConnectionStatusUpdate);
         m_TTAPI.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();
     }
     else if (!ex.IsRecoverable)
     {
         MessageBox.Show("API Initialization Failed: " + ex.Message);
     }
 }
Example #3
0
 /// <summary>
 /// Event notification for status of TT API initialization
 /// </summary>
 public void ttApiInitComplete(TTAPI api, ApiCreationException ex)
 {
     if (ex == null)
     {
         // Authenticate your credentials
         m_apiInstance = (XTraderModeTTAPI)api;
         m_apiInstance.ConnectionStatusUpdate += new EventHandler <ConnectionStatusUpdateEventArgs>(m_apiInstance_ConnectionStatusUpdate);
         m_apiInstance.Start();
     }
     else
     {
         Console.WriteLine("TT API Initialization Failed: {0}", ex.Message);
         Dispose();
     }
 }
Example #4
0
        }// TT_AuthenticationStatusUpdate()

        //
        // *********************************************************************
        // ****                 TT XTrader Init Complete                    ****
        // *********************************************************************
        private void TT_XTraderInitComplete(TTAPI api, Exception ex)
        {
            if (ex == null)
            {
                m_XAPI = (XTraderModeTTAPI)api;
                if (m_Log != null)
                {
                    m_Log.NewEntry(LogLevel.Major, "XTraderInitComplete: API Xtrader initialization is successful.");
                }
                m_XAPI.ConnectionStatusUpdate += new EventHandler <ConnectionStatusUpdateEventArgs>(TT_ConnectionStatusUpdate);
                m_XAPI.LicenseIssue           += new EventHandler <LicenseIssueEventArgs>(TT_LicenseIssueEventHandler);
                m_XAPI.XTraderStatusChanged   += new EventHandler <TradingTechnologies.TTAPI.XTInteraction.XTraderStatusChangedEventArgs>(TT_XTraderStatusChanged);

                if (string.IsNullOrEmpty(m_XAPI.Session.UserName))
                {   // There is no user logged into the x-trader session.
                    // We will need to wait until one shows up.
                    if (m_XTraderLoginTimer == null)
                    {
                        double waitTimeMinutes = 0.20;
                        if (m_Log != null)
                        {
                            m_Log.NewEntry(LogLevel.Major, "XTraderInitComplete: No user logged into XTrader yet. Will check again in {0:0.0} minutes.", waitTimeMinutes);
                        }
                        m_XTraderLoginTimer           = new System.Timers.Timer();
                        m_XTraderLoginTimer.AutoReset = false;
                        m_XTraderLoginTimer.Elapsed  += XTraderLoginTimerCallback;
                        m_XTraderLoginTimer.Interval  = waitTimeMinutes * (60000.0);   // minutes * (msecs/min)
                        m_XTraderLoginTimer.Enabled   = true;
                        return;
                    }
                }
                else
                {
                    m_XAPI.Start();
                }
            }
            else
            {
                if (m_Log != null)
                {
                    m_Log.NewEntry(LogLevel.Error, "XTraderInitComplete: Xtrader initialization failed. Exception {0}. Will try again.", ex.Message);
                }
                Thread.Sleep(10000);
                m_Dispatcher.BeginInvoke(new Action(m_XAPI.Start));
            }
        }//TT_XTraderInitComplete()
        /// <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);
            }
        }