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); } }
/// <summary> /// Initialize TT API /// </summary> public void Init() { // Use "Follow X_TRADER" Login Mode ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete); TTAPI.CreateXTraderModeTTAPI(Dispatcher.Current, h); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Initialize the API </summary> //////////////////////////////////////////////////////////////////////////////////////////////////// public void Init(tt_net_sdk.TTAPIOptions apiConfig) { ApiInitializeHandler apiInitializeHandler = new ApiInitializeHandler(ttNetApiInitHandler); TTAPI.ShutdownCompleted += TTAPI_ShutdownCompleted; TTAPI.CreateTTAPI(tt_net_sdk.Dispatcher.Current, apiConfig, apiInitializeHandler); }
static void Main() { using (Dispatcher disp = Dispatcher.AttachUIDispatcher()) { Application.EnableVisualStyles(); // Create an instance of the API MarketExplorer marketExplorer = new MarketExplorer(); // Add your app secret Key here. It looks like: 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000 string appSecretKey = "Add your app secret Key here"; // Add the host machine instance id assigned to you by TT only needed for Server mode. If set in // Client mode, it will simply be ignored string instanceId = "Add your host machine instance id here"; // Set the environment the app needs to run in here tt_net_sdk.ServiceEnvironment environment = tt_net_sdk.ServiceEnvironment.UatCert; // Select the mode in which you wish to run -- Client (outside the TT datacenter) // or Server (on a dedicated machine inside TT datacenter) tt_net_sdk.TTAPIOptions.SDKMode sdkMode = tt_net_sdk.TTAPIOptions.SDKMode.Client; tt_net_sdk.TTAPIOptions apiConfig = new tt_net_sdk.TTAPIOptions( sdkMode, environment, appSecretKey, 5000); // set the instance id and any other options needed apiConfig.ServerInstanceId = instanceId; ApiInitializeHandler handler = new ApiInitializeHandler(marketExplorer.ttNetApiInitHandler); TTAPI.CreateTTAPI(disp, apiConfig, handler); Application.Run(marketExplorer); } }
/// <summary> /// Initialize TT API /// </summary> public void Init() { // Use "Universal Login" Login Mode ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete); TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, m_username, m_password, h); }
/// <summary> /// Initialize TT API /// </summary> public void Init() { cout("TengineTT::Init: Initializing TTAPI..."); // Use "Universal Login" Login Mode ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete); TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, Username, Password, h); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Initialize the API </summary> //////////////////////////////////////////////////////////////////////////////////////////////////// public void Init(tt_net_sdk.TTAPIOptions apiConfig) { ApiInitializeHandler apiInitializeHandler = new ApiInitializeHandler(ttNetApiInitHandler); TTAPI.ShutdownCompleted += TTAPI_ShutdownCompleted; //For Algo Orders apiConfig.AlgoUserDisconnectAction = UserDisconnectAction.Cancel; TTAPI.CreateTTAPI(tt_net_sdk.Dispatcher.Current, apiConfig, apiInitializeHandler); }
public void Init(Form1 f, bool sim) { MainForm = f; //Init details if (!sim) { m_username = "******"; m_password = "******"; } //API connection m_disp = Dispatcher.AttachUIDispatcher(); ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete); TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, m_username, m_password, h); }
/// <summary> /// Initialize TT API /// </summary> private void Init() { log.Info("Connecting to TT API..."); try { // Use "Universal Login" Login Mode ApiInitializeHandler h = InitComplete; TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, _username, _password, h); } catch (Exception) { log.Info("Connection failed"); } }
static void Main() { // Confirm TTAPI installation archetecture. AboutDTS.TTAPIArchitectureCheck(); using (Dispatcher disp = Dispatcher.AttachUIDispatcher()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Create an instance of TTAPI. AutospreaderManagerForm autospreaderManagerForm = new AutospreaderManagerForm(); ApiInitializeHandler handler = new ApiInitializeHandler(autospreaderManagerForm.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, handler); Application.Run(autospreaderManagerForm); } }
/// <summary> /// Attempt to authenticate the user. /// </summary> private void btnConnect_Click(object sender, EventArgs e) { // Check to ensure that values have been entered for all fields if (txtUsername.Text == String.Empty) { MessageBox.Show("Please enter a username"); return; } if (txtPassword.Text == String.Empty) { MessageBox.Show("Please enter a Password"); return; } ApiInitializeHandler handler = new ApiInitializeHandler(ttApiInitHandler); TTAPI.CreateUniversalLoginTTAPI(m_dispatcher, txtUsername.Text, txtPassword.Text, handler); }
static void Main() { using (var disp = Dispatcher.AttachUIDispatcher()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 form1 = new Form1(); ApiInitializeHandler handler = new ApiInitializeHandler(form1.ttApiInitHandler); TTAPI.CreateUniversalLoginTTAPI(disp, "ekocatulum","rubicon1789",handler); Application.Run(form1); } }
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(); ApiInitializeHandler handler = new ApiInitializeHandler(orderFilter.ttApiInitHandler); TTAPI.CreateXTraderModeTTAPI(disp, handler); Application.Run(orderFilter); } }
static void Main() { using (Dispatcher disp = Dispatcher.AttachUIDispatcher()) { Application.EnableVisualStyles(); // Create an instance of the API MarketExplorer marketExplorer = new MarketExplorer(); // Add your app secret Key here. It looks like: 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000 string appSecretKey = "240bc7e6-ba70-b3eb-b99c-28b34865525b:91ecb109-b5fc-5eaf-96ab-af8539b8fd5a"; tt_net_sdk.ServiceEnvironment environment = tt_net_sdk.ServiceEnvironment.DevCert; tt_net_sdk.TTAPIOptions apiConfig = new tt_net_sdk.TTAPIOptions(environment, appSecretKey, 5000); ApiInitializeHandler handler = new ApiInitializeHandler(marketExplorer.ttNetApiInitHandler); TTAPI.CreateTTAPI(disp, apiConfig, handler); Application.Run(marketExplorer); } }
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() { using (Dispatcher disp = Dispatcher.AttachUIDispatcher()) { Application.EnableVisualStyles(); // Create an instance of the API MarketExplorer marketExplorer = new MarketExplorer(); // Add your app secret Key here. It looks like: 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000 string appSecretKey = "Add your app secret Key here"; tt_net_sdk.ServiceEnvironment environment = tt_net_sdk.ServiceEnvironment.UatCert; tt_net_sdk.TTAPIOptions apiConfig = new tt_net_sdk.TTAPIOptions(environment, appSecretKey, 5000); ApiInitializeHandler handler = new ApiInitializeHandler(marketExplorer.ttNetApiInitHandler); TTAPI.CreateTTAPI(disp, apiConfig, handler); Application.Run(marketExplorer); } }
}// 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
public void Init(TTAPIOptions apiConfig) { ApiInitializeHandler apiInitializeHandler = new ApiInitializeHandler(ttNetApiInitHandler); TTAPI.CreateTTAPI(Dispatcher.Current, apiConfig, apiInitializeHandler); }