public void setup() { //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); if (!isserverconok) { server = new TradeLink.Common.TLServer_WM(); con = new IQFeedHelper(server); con.VerboseDebugging = verbosesetting; con.SendDebug += new DebugDelegate(g.d); // get login information var data = Util.getfile(loginfile, g.d); Assert.IsFalse(string.IsNullOrWhiteSpace(data), "no login info"); var li = data.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(3, li.Length, "missing login info"); // attempt to startup connection con.Start(li[userr], li[pwr], li[prodr], Util.TLBuild()); // wait a moment Util.sleep(4000); Assert.IsTrue(isserverconok, "server connection failed"); } if (isserverconok && !isclientconok) { var c = new TLClient_WM("tempiqclient", false); c.VerboseDebugging = verbosesetting; c.SendDebugEvent += new DebugDelegate(g.d); if (c.ProvidersAvailable[0]!= Providers.IQFeed) throw new Exception("unable to find test server"); c.Mode(0, false); client = c; client.gotUnknownMessage += new MessageDelegate(client_gotUnknownMessage); // verify Assert.IsTrue(isclientconok, "client connection failed"); } // reset everything mt = new MessageTracker(); mt.VerboseDebugging = verbosesetting; blt = new BarListTracker(); mt.BLT = blt; mt.SendDebug += new DebugDelegate(g.d); mt.GotNewBar += new SymBarIntervalDelegate(mt_GotNewBar); recvbarcount = 0; msgok = true; g.d("iqfeed started."); // wait a moment Util.sleep(1000); }
void initfeeds() { if ((_bf == null) || (_ao==null)) { debug("a problem has occured. ASP must be run in interactive mode."); return; } // try to connect to preferr providers _bf.Reset(); // update ASP gui with available providers _ao._execsel.DataSource = getproviderlist(_bf.ProvidersAvailable); _ao._datasel.DataSource = getproviderlist(_bf.ProvidersAvailable); // if we have quotes if (_bf.isFeedConnected) { // don't save ticks from replay since they're already saved _ao.archivetickbox.Checked = (_bf.ProvidersAvailable.Length > 0) && !_bf.FeedClient.RequestFeatureList.Contains(MessageTypes.HISTORICALDATA); // monitor quote feed twice as frequently as the timeout interval int timeout = (int)Properties.Settings.Default.brokertimeoutsec; int poll = (int)(((double)timeout* 1000)/ 2); debug(poll == 0 ? "connection timeout disabled." : "using connection timeout: " + poll); _tlt = new TLTracker(poll, timeout, _bf.FeedClient, Providers.Unknown, true); _tlt.GotConnectFail += new VoidDelegate(_tlt_GotConnectFail); _tlt.GotConnect += new VoidDelegate(_tlt_GotConnect); _tlt.GotDebug += new DebugDelegate(_tlt_GotDebug); // update selected providers in ASP gui _ao._datasel.SelectedIndex = _bf.FeedClient.ProviderSelected; _ao._datasel.Text = _bf.FeedClient.BrokerName.ToString() + " " + _bf.FeedClient.ProviderSelected; // notify status("Connected: " + _bf.Feed); } if (_bf.isBrokerConnected) { // if we have execs _ao._execsel.SelectedIndex = _bf.BrokerClient.ProviderSelected; _ao._execsel.Text = _bf.BrokerName.ToString() + " " + _bf.BrokerClient.ProviderSelected; } // hook up events _bf.gotFill += new FillDelegate(tl_gotFill); _bf.gotOrder += new OrderDelegate(tl_gotOrder); _bf.gotOrderCancel += new LongDelegate(tl_gotOrderCancel); _bf.gotPosition += new PositionDelegate(tl_gotPosition); _bf.gotTick += new TickDelegate(quote_gotTick); _bf.gotUnknownMessage += new MessageDelegate(tl_gotUnknownMessage); _bf.gotImbalance += new ImbalanceDelegate(tl_gotImbalance); // intercept imbalance messages // pass messages through _mtquote = new MessageTracker(_bf.FeedClient); _mtquote.SendMessageResponse += new MessageDelegate(tl_gotUnknownMessage); _mtquote.SendDebug += new DebugDelegate(_mt_SendDebug); _mtexec = new MessageTracker(_bf.BrokerClient); _mtexec.SendMessageResponse += new MessageDelegate(tl_gotUnknownMessage); _mtexec.SendDebug += new DebugDelegate(_mt_SendDebug); _mtconnect = new MessageTracker(_bf); _mtconnect.SendMessageResponse+=new MessageDelegate(tl_gotUnknownMessage); _mtconnect.SendDebug+=new DebugDelegate(_mt_SendDebug); // startup _tlt_GotConnect(); }