Example #1
0
        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);
            }
            _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);
            }
        }