static void Main() { // confirm TTAPI installation archetecture AboutDTS.TTAPIArchitectureCheck(); XTraderModeTTAPIOptions envOptions = new XTraderModeTTAPIOptions(); // Enable or Disable the TT API Implied Engine envOptions.EnableImplieds = false; envOptions.SupportPublishSOD = true; // 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. frmSOD_ManualFill sodManualFill = new frmSOD_ManualFill(); ApiInitializeHandler handler = new ApiInitializeHandler(sodManualFill.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, envOptions, handler); Application.Run(sodManualFill); } }
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); // Create an instance of TTAPI. frmTimeAndSales timeAndSales = new frmTimeAndSales(); ApiInitializeHandler handler = new ApiInitializeHandler(timeAndSales.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, handler); Application.Run(timeAndSales); } }
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. frmFillUpdate fillUpdate = new frmFillUpdate(); ApiInitializeHandler handler = new ApiInitializeHandler(fillUpdate.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, handler); Application.Run(fillUpdate); } }
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); } }
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. frmFillUpdate fillUpdate = new frmFillUpdate(); ApiInitializeHandler handler = new ApiInitializeHandler(fillUpdate.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, handler); Application.Run(fillUpdate); } }
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); } }
}// 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."); } ApiInitializeHandler d = new ApiInitializeHandler(TT_XTraderInitComplete); // new method for 7.17.X TTAPI //TTAPI.XTraderModeDelegate d = new TTAPI.XTraderModeDelegate(TT_XTraderInitComplete); // old method for 7.2.X TTAPI 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 ApiInitializeHandler ulDelegate = new ApiInitializeHandler(TT_UniversalInitComplete); // Call back after API is created. try { TTAPI.CreateUniversalLoginTTAPI(m_Dispatcher, m_UserName, m_Password, ulDelegate); } catch (Exception e) { if (m_Log != null) { m_Log.NewEntry(LogLevel.Warning, "InitAPI: TT Exception {0}.", e.Message); } if (m_AlertManager != null) { m_AlertManager.RequestEmailAlert(AlertLevel.High, "InitAPI: TT Exception {0}.", e.Message); } } } //System.Windows.Forms.MessageBox.Show("test TT2"); }// InitAPI()
static void Main() { string ttUserId = "PRIMEDTS2"; string ttPassword = "******"; // 0 = Console App // 1 = Test2Form (CTS T4API) // 11 TestForm (TTAPI) modified to create ttapi within Form // 2 = TestForm (TTAPI) // 21 = modified TTAPI Console App for TeTTApi // 3 = CryptosAPIsTest.Test() // 31 = CryptoTestForm // 4 = TTAPIFunctions Console App // 5 = another TTAPI test Form (not working) int startup = 31; //---------------------------------------------------------------------------------------------------------- // Startup as Console App if (startup == 0) { var main = new ZeroSumAPI.Main(); main.Test1(); Console.WriteLine("\nPress any key..."); Console.ReadKey(); } //---------------------------------------------------------------------------------------------------------- if (startup == 1) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Test2Form()); } //---------------------------------------------------------------------------------------------------------- if (startup == 11) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestForm()); } if (startup == 12) { // 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); // Create an instance of TTAPI. frmPriceUpdate priceUpdate = new frmPriceUpdate(); ApiInitializeHandler handler = new ApiInitializeHandler(priceUpdate.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, handler); var frmTest = new Test3Form(priceUpdate); Application.Run(frmTest); } } //---------------------------------------------------------------------------------------------------------- if (startup == 2) { // confirm TTAPI installation archetecture //AboutDTS.TTAPIArchitectureCheck(); TTAPIArchitectureCheck archCheck = new TTAPIArchitectureCheck(); if (archCheck.validate()) { Console.WriteLine("Architecture check passed."); 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 TeTTApi. TengineTT api = new TengineTT(); //ApiInitializeHandler handler = new ApiInitializeHandler(ttapi.ttApiInitHandler); //TTAPI.CreateXTraderModeTTAPI(disp, handler); //TestForm testForm = new TestForm(ttapi); //Application.Run(testForm); } } else { ErrorMessage("TTAPIArchitectureCheck FAILED!"); } return; } //---------------------------------------------------------------------------------------------------------- if (startup == 21) { // Check that the compiler settings are compatible with the version of TT API installed TTAPIArchitectureCheck archCheck = new TTAPIArchitectureCheck(); if (archCheck.validate()) { Console.WriteLine("Architecture check passed."); // Dictates whether TT API will be started on its own thread bool startOnSeparateThread = true; if (startOnSeparateThread) { cout("Starting TTAPI on SEPARATE thread"); // Start TT API on a separate thread TengineTT api = new TengineTT(); Thread workerThread = new Thread(api.Start); workerThread.Name = "TeTTApi TradingEngine Thread"; workerThread.Start(); // Insert other code here that will run on this thread Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestForm()); } else { cout("Starting TTAPI on same thread"); // Start the TT API on the same thread using (TengineTT api = new TengineTT()) { api.Start(); } } } else { Console.WriteLine("Architecture check failed. {0}", archCheck.ErrorString); } } //---------------------------------------------------------------------------------------------------------- if (startup == 3) { var crypto = new CryptoAPIsTest(); crypto.Test(); return; } //---------------------------------------------------------------------------------------------------------- if (startup == 31) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new CryptoTestForm()); } //---------------------------------------------------------------------------------------------------------- if (startup == 4) { // Check that the compiler settings are compatible with the version of TT API installed TTAPIArchitectureCheck archCheck = new TTAPIArchitectureCheck(); if (archCheck.validate()) { Console.WriteLine("Architecture check passed."); // Dictates whether TT API will be started on its own thread bool startOnSeparateThread = false; if (startOnSeparateThread) { // Start TT API on a separate thread TTAPIFunctions tf = new TTAPIFunctions(ttUserId, ttPassword); Thread workerThread = new Thread(tf.Start); workerThread.Name = "TT API Thread"; workerThread.Start(); // Insert other code here that will run on this thread } else { // Start the TT API on the same thread using (TTAPIFunctions tf = new TTAPIFunctions(ttUserId, ttPassword)) { tf.Start(); } } } else { Console.WriteLine("Architecture check failed. {0}", archCheck.ErrorString); } } //---------------------------------------------------------------------------------------------------------- if (startup == 5) { /*// 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(); * TeTTApiForm ttapi = new TeTTApiForm(); * ApiInitializeHandler handler = new ApiInitializeHandler(ttapi.ttApiInitHandler); * TTAPI.CreateXTraderModeTTAPI(disp, handler); * * Application.Run(ttapi); * }*/ } //---------------------------------------------------------------------------------------------------------- } // end of Main