Exemplo n.º 1
0
        static void Main()
        {
            // Confirm TTAPI installation archetecture.
            AboutDTS.TTAPIArchitectureCheck();

            using (Dispatcher dispatcher = Dispatcher.AttachUIDispatcher())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Create an instance of TTAPI.
                frmMarketExplorer marketExplorer = new frmMarketExplorer();
                TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(marketExplorer.initTTAPI);
                TTAPI.CreateXTraderModeTTAPI(dispatcher, xtDelegate);

                Application.Run(marketExplorer);
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            // Attach a UIDispatcher to the current thread
            using (UIDispatcher disp = Dispatcher.AttachUIDispatcher())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Form1 f = new Form1();

                // Use "Follow X_TRADER" Login Mode
                TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(f.ttApiInitComplete);
                TTAPI.CreateXTraderModeTTAPI(Dispatcher.Current, xtDelegate);

                Application.Run(f);

                // Shutdown the TT API
                f.shutdownTTAPI();
            }
        }
Exemplo n.º 3
0
        static void Main()
        {
            // confirm TTAPI installation archetecture
            AboutDTS.TTAPIArchitectureCheck();

            // Create and attach a UI Dispatcher to the main Form
            // When the form exits, this scoping block will auto-dispose of the Dispatcher
            using (var disp = Dispatcher.AttachUIDispatcher())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Create an instance of TTAPI.
                frmOrderFilter orderFilter = new frmOrderFilter();
                TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(orderFilter.initTTAPI);
                TTAPI.CreateXTraderModeTTAPI(disp, xtDelegate);

                Application.Run(orderFilter);
            }
        }
Exemplo n.º 4
0
        static void Main()
        {
            XTraderModeTTAPIOptions envOptions = new XTraderModeTTAPIOptions();
            // Enable or Disable the TT API Implied Engine
            envOptions.EnableImplieds = false;

            // Create and attach a UI Dispatcher to the main Form
            // When the form exits, this scoping block will auto-dispose of the Dispatcher
            using (var disp = Dispatcher.AttachUIDispatcher())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Create an instance of TTAPI.
                frmProfitLoss profitLoss = new frmProfitLoss();
                TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(profitLoss.initTTAPI);
                TTAPI.CreateXTraderModeTTAPI(disp, xtDelegate);

                Application.Run(profitLoss);
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            // confirm TTAPI installation archetecture
            AboutDTS.TTAPIArchitectureCheck();

            XTraderModeTTAPIOptions envOptions = new XTraderModeTTAPIOptions();
            // Enable or Disable the TT API Implied Engine
            envOptions.EnableImplieds = false;

            // Create and attach a UI Dispatcher to the main Form
            // When the form exits, this scoping block will auto-dispose of the Dispatcher
            using (var disp = Dispatcher.AttachUIDispatcher())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                frmPriceUpdateManual priceUpdateManualConnection = new frmPriceUpdateManual();
                TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(priceUpdateManualConnection.initTTAPI);
                TTAPI.CreateXTraderModeTTAPI(disp, xtDelegate);

                Application.Run(priceUpdateManualConnection);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initialize the TTAPI in XTrader mode
 /// </summary>
 public void InitXTMode()
 {
     // Use "XTrader Mode Login" login mode
     TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(ttApiXTModeInitComplete);
     TTAPI.CreateXTraderModeTTAPI(Dispatcher.Current, xtDelegate);
 }
        /// <summary>
        /// Start TT API and attach the dispatcher to this thread.
        /// </summary>
        private void startTTAPI()
        {
            m_dispatcher = Dispatcher.AttachUIDispatcher();

            // Create an instance of TTAPI.
            TTAPI.XTraderModeDelegate xtDelegate = new TTAPI.XTraderModeDelegate(initTTAPI);
            TTAPI.CreateXTraderModeTTAPI(m_dispatcher, xtDelegate);
        }
Exemplo n.º 8
0
        }// StartInitAPI().

        //
        /// <summary>
        /// Create UniversalLogin or XTrader API instance.
        /// Called by the TTService worker thread.
        /// </summary>
        private void InitAPI()
        {
            if (m_UseXTraderLogin)
            {   // Follow the local XTrader login.
                // Note: This will not fail even if no XTrader is running.
                // Rather, the call m_XAPI.ConnectToXTrader(), below, will get stuck forever if there is not XTrader running.
                //System.Windows.Forms.MessageBox.Show("test TT1");
                // Check for Xtrader process, postpone connecting if its NOT running.
                //System.Windows.Forms.MessageBox.Show("test5");
                System.Diagnostics.Process[] procs = null;
                try
                {
                    if (m_CheckXTraderProcessExists)
                    {
                        procs = System.Diagnostics.Process.GetProcessesByName("x_trader");
                    }
                }
                catch (Exception e)
                {
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Exception {0}.  Turning off XTrader searching.  Will try to start API directly.", e.Message);
                    }
                    m_CheckXTraderProcessExists = false;                    // Ok, security issues may have caused this to fail.  Nothing to do be proceed.
                }
                if (m_CheckXTraderProcessExists && procs != null && procs.Length < 1)
                {   // There is NO Xtrader running.
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Found NO XTrader process. Waiting {0} secs to look again.", m_WaitForAPISeconds);
                    }
                    Thread.Sleep(1000 * m_WaitForAPISeconds);
                    try
                    {
                        if (!m_Stopping && m_Dispatcher != null)
                        {
                            m_Dispatcher.BeginInvoke(new Action(InitAPI));
                        }
                    }
                    catch (Exception e)
                    {   // This exception can happen when we are shutting down, before we connect.
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Exception when re-invoking. Exiting. Exception = {0}.", e.Message);
                    }
                }
                else
                {   // XTrader is running, connect to it.
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Creating XTrader mode API.");
                    }
                    TTAPI.XTraderModeDelegate d       = new TTAPI.XTraderModeDelegate(TT_XTraderInitComplete);
                    XTraderModeTTAPIOptions   options = new XTraderModeTTAPIOptions();
                    options.XTServicesConnectionTimeout = new TimeSpan(0, 0, 20);
                    try
                    {
                        TTAPI.CreateXTraderModeTTAPI(m_Dispatcher, options, d);
                    }
                    catch (Exception e)
                    {
                        if (m_Log != null)
                        {
                            m_Log.NewEntry(LogLevel.Warning, "InitAPI: TT Exception {0}.", e.Message);
                        }
                    }
                }
            }
            else
            {                                                                                                                 // Use "Universal Login" Login Mode
                TTAPI.UniversalLoginModeDelegate ulDelegate = new TTAPI.UniversalLoginModeDelegate(TT_UniversalInitComplete); // Call back after API is created.
                try
                {
                    TTAPI.CreateUniversalLoginTTAPI(m_Dispatcher, ulDelegate);
                }
                catch (Exception e)
                {
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: TT Exception {0}.", e.Message);
                    }
                }
            }
            //System.Windows.Forms.MessageBox.Show("test TT2");
        }// InitAPI()