public RecordMain() { TrackEnabled = Util.TrackUsage(); Program = PROGRAM; InitializeComponent(); Text += " " + Util.TLVersion(); string ipaddr = Properties.Settings.Default.ServerIpAddresses; string[] servers = ipaddr.Split(','); if (ipaddr==string.Empty) tl = new TLClient_WM(); else tl = new TLClient_IP(servers, Properties.Settings.Default.ServerPort, debug); int pollms = (int)(((double)Properties.Settings.Default.brokertimeoutsec * 1000) / 2); _tlt = new TLTracker(pollms, Properties.Settings.Default.brokertimeoutsec, tl, Providers.Unknown, true); _tlt.GotConnect += new VoidDelegate(_tlt_GotConnect); _tlt.GotConnectFail += new VoidDelegate(_tlt_GotConnectFail); _tlt.GotDebug += new DebugDelegate(_tlt_GotDebug); ContextMenu = new ContextMenu(); ContextMenu.MenuItems.Add("SymbolList", new EventHandler(symlist)); ContextMenu.MenuItems.Add("Level2", new EventHandler(level2)); ContextMenu.MenuItems.Add("Timeout", new EventHandler(timeout)); ContextMenu.MenuItems.Add("ReportBug", new EventHandler(report)); ContextMenu.MenuItems.Add("Messages", new EventHandler(togdebug)); if (tl.ProvidersAvailable.Length > 0) { if (tl.BrokerName != Providers.TradeLink) { if (Environment.ProcessorCount == 1) tl.gotTick += new TickDelegate(tl_gotTick); else { tl.gotTick += new TickDelegate(tl_gotTick2); _ar.GotTick += new TickDelegate(tl_gotTick); } } } TradeLink.AppKit.Versions.UpgradeAlert(tl); FormClosing += new FormClosingEventHandler(RecordMain_FormClosing); // process command line processcommands(); }
void initfeeds() { string[] servers = Properties.Settings.Default.ServerIpAddresses.Split(','); _bf = new BrokerFeed(Properties.Settings.Default.PreferredQuote, Properties.Settings.Default.PreferredExec, Properties.Settings.Default.FallbackToAnyProvider, false,PROGRAM,servers,Properties.Settings.Default.ServerPort); _bf.SendDebugEvent+=new DebugDelegate(debug); _bf.Reset(); // if our machine is multi-core we use seperate thread to process ticks if (Environment.ProcessorCount == 1) _bf.gotTick += new TickDelegate(tl_gotTick); else { _bf.gotTick += new TickDelegate(tl_gotTickasync); _ar.GotTick += new TickDelegate(tl_gotTick); } ord.VerboseDebugging = true; ord.SendDebugEvent+=new DebugDelegate(debug); _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.gotAccounts += new DebugDelegate(tl_gotAccounts); // monitor quote feed if (_bf.isFeedConnected) { int poll = (int)((double)Properties.Settings.Default.brokertimeoutsec * 1000 / 2); debug(poll == 0 ? "connection timeout disabled." : "using connection timeout: " + poll); _tlt = new TLTracker(poll, (int)Properties.Settings.Default.brokertimeoutsec, _bf.FeedClient, Providers.Unknown, true); _tlt.GotConnectFail += new VoidDelegate(_tlt_GotConnectFail); _tlt.GotConnect += new VoidDelegate(_tlt_GotConnect); _tlt.GotDebug += new DebugDelegate(_tlt_GotDebug); status("Connected: " + _bf.Feed); } }
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(); }