public bool Mode(int ProviderIndex, bool showwarning) { _linktype = TLTypes.NONE; // reset before changing link mode if ((ProviderIndex >= srvrwin.Count) || (ProviderIndex < 0)) { if (showwarning) { System.Windows.Forms.MessageBox.Show("Invalid broker specified or no brokers running.", "TradeLink server not found"); } return(false); } try { Disconnect(); himh = WMUtil.HisHandle(srvrwin[ProviderIndex]); _linktype = TLTypes.LIVEBROKER; Register(); RequestFeatures(); _curprovider = ProviderIndex; return(true); } catch (TLServerNotFound) { if (showwarning) { System.Windows.Forms.MessageBox.Show("No Live broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); } return(false); } catch (Exception) { return(false); } }
public void StartupTests() { // we're expecting this server type TLTypes expect = TLTypes.HISTORICALBROKER; // discover our states TLTypes FOUND = c.TLFound(); bool CONNECTED = c.Mode(FOUND & expect, true, false); // should be able to connect to whatever server we find Assert.That(CONNECTED, "make sure you don't have TLServers running"); }
void FetchTLServer() { TLTypes servers = tl.TLFound(); if (tl.Mode(servers, true)) { string name = tl.BrokerName.ToString(); status("Found TradeLink broker server: " + name); show("Found TradeLink broker server: " + name); } else { status("Unable to find any broker instance. Do you have one running?"); } }
public TLTypes TLFound() { TLTypes f = TLTypes.NONE; if (WMUtil.Found(WMUtil.SIMWINDOW)) { f |= TLTypes.SIMBROKER; } if (WMUtil.Found(WMUtil.LIVEWINDOW)) { f |= TLTypes.LIVEBROKER; } if (WMUtil.Found(WMUtil.REPLAYWINDOW)) { f |= TLTypes.HISTORICALBROKER; } return(f); }
/// <summary> /// Makes TL client use Broker Simulation mode (Broker must be logged in and TradeLink loaded) /// </summary> public void GoSim() { Disconnect(); himh = WMUtil.HisHandle(WMUtil.SIMWINDOW); LinkType = TLTypes.SIMBROKER; Register(); }
/// <summary> /// Attemptions connection to TL Replay Server /// </summary> public void GoHist() { Disconnect(); himh = WMUtil.HisHandle(WMUtil.REPLAYWINDOW); LinkType = TLTypes.HISTORICALBROKER; Register(); }
public TLServer_WM(TLTypes servertype) : this(servertype==TLTypes.LIVEBROKER? WMUtil.LIVEWINDOW : (servertype == TLTypes.SIMBROKER ? WMUtil.SIMWINDOW : (servertype== TLTypes.HISTORICALBROKER? WMUtil.REPLAYWINDOW : WMUtil.TESTWINDOW))) { }
/// <summary> /// Makes TL client use Broker LIVE server (Broker must be logged in and TradeLink loaded) /// </summary> public void GoLive() { Disconnect(); himh = WMUtil.HisHandle(WMUtil.LIVEWINDOW); LinkType = TLTypes.LIVEBROKER; Register(); }
public bool Mode(TLTypes mode, bool throwexceptions, bool showwarning) { bool HandleExceptions = !throwexceptions; LinkType = TLTypes.NONE; // reset before changing link mode switch (mode) { case TLTypes.LIVEBROKER: if (HandleExceptions) { try { GoLive(); return(true); } catch (TLServerNotFound) { if (showwarning) { System.Windows.Forms.MessageBox.Show("No Live broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); } return(false); } } else { GoLive(); } break; case TLTypes.SIMBROKER: if (HandleExceptions) { try { GoSim(); return(true); } catch (TLServerNotFound) { if (showwarning) { System.Windows.Forms.MessageBox.Show("No simulation broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); } return(false); } } else { GoSim(); } return(true); case TLTypes.HISTORICALBROKER: if (HandleExceptions) { try { GoHist(); return(true); } catch (TLServerNotFound) { if (showwarning) { System.Windows.Forms.MessageBox.Show("No historical broker instance found. Make sure Replay Server is running."); } return(false); } } else { GoHist(); } return(true); case TLTypes.TESTBROKER: if (HandleExceptions) { try { GoTest(); return(true); } catch (TLServerNotFound) { if (showwarning) { System.Windows.Forms.MessageBox.Show("No test broker instance found. Make sure you started a TradeLink_Server object with TLType.TEST."); } return(false); } } else { GoTest(); } return(true); default: if (showwarning) { System.Windows.Forms.MessageBox.Show("No valid broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); } break; } return(false); }
public TradeLink_Server_WM(TLTypes servertype) : this(servertype == TLTypes.LIVEBROKER? WMUtil.LIVEWINDOW : (servertype == TLTypes.SIMBROKER ? WMUtil.SIMWINDOW : (servertype == TLTypes.HISTORICALBROKER? WMUtil.REPLAYWINDOW : WMUtil.TESTWINDOW))) { }
public bool Mode(TLTypes mode, bool showarning) { return Mode(mode, false, showarning); }
public bool Mode(int ProviderIndex, bool showwarning) { _linktype = TLTypes.NONE; // reset before changing link mode if ((ProviderIndex >= srvrwin.Count) || (ProviderIndex < 0)) { if (showwarning) System.Windows.Forms.MessageBox.Show("Invalid broker specified or no brokers running.", "TradeLink server not found"); return false; } try { Disconnect(); himh = WMUtil.HisHandle(srvrwin[ProviderIndex]); _linktype = TLTypes.LIVEBROKER; Register(); RequestFeatures(); _curprovider = ProviderIndex; return true; } catch (TLServerNotFound) { if (showwarning) System.Windows.Forms.MessageBox.Show("No Live broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); return false; } catch (Exception) { return false; } }
/// <summary> /// Used for testing the TL-BROKER api (programmatically) /// </summary> public void GoTest() { Disconnect(); himh = WMUtil.HisHandle(WMUtil.TESTWINDOW); LinkType = TLTypes.TESTBROKER; Register(); }
/// <summary> /// Sets the preferred communication channel of the link, if multiple channels are avaialble. /// </summary> /// <param name="mode">The mode.</param> /// <returns></returns> public bool Mode(TLTypes mode) { return Mode(mode, false, true); }
/// <summary> /// Sets the preferred communication channel of the link, if multiple channels are avaialble. /// </summary> /// <param name="mode">The mode.</param> /// <returns></returns> public bool Mode(TLTypes mode) { return(Mode(mode, false, true)); }
public bool Mode(TLTypes mode, bool throwexceptions, bool showwarning) { bool HandleExceptions = !throwexceptions; LinkType = TLTypes.NONE; // reset before changing link mode switch (mode) { case TLTypes.LIVEBROKER: if (HandleExceptions) { try { GoLive(); return true; } catch (TLServerNotFound) { if (showwarning) System.Windows.Forms.MessageBox.Show("No Live broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); return false; } } else GoLive(); break; case TLTypes.SIMBROKER: if (HandleExceptions) { try { GoSim(); return true; } catch (TLServerNotFound) { if (showwarning) System.Windows.Forms.MessageBox.Show("No simulation broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); return false; } } else GoSim(); return true; break; case TLTypes.HISTORICALBROKER: if (HandleExceptions) { try { GoHist(); return true; } catch (TLServerNotFound) { if (showwarning) System.Windows.Forms.MessageBox.Show("No historical broker instance found. Make sure Replay Server is running."); return false; } } else GoHist(); return true; break; case TLTypes.TESTBROKER: if (HandleExceptions) { try { GoTest(); return true; } catch (TLServerNotFound) { if (showwarning) System.Windows.Forms.MessageBox.Show("No test broker instance found. Make sure you started a TradeLink_Server object with TLType.TEST."); return false; } } else GoTest(); return true; break; default: if (showwarning) System.Windows.Forms.MessageBox.Show("No valid broker instance was found. Make sure broker application + TradeLink server is running.", "TradeLink server not found"); break; } return false; }
public bool Mode(TLTypes mode, bool showarning) { return(Mode(mode, false, showarning)); }