Пример #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);
            }
        }
Пример #2
0
 public ASP()
 {
     TrackEnabled = Util.TrackUsage();
     Program = PROGRAM;
     // read designer options for gui
     InitializeComponent();
     // show status
     status(Util.TLSIdentity());
     debug(Util.TLSIdentity());
     // count instances of program
     _ASPINSTANCE = getprocesscount(PROGRAM)-1;
     // ensure have not exceeded maximum
     if ((_ASPINSTANCE + 1) > MAXASPINSTANCE)
     {
         MessageBox.Show("You have exceeded maximum # of running ASPs (" + MAXASPINSTANCE + ")." + Environment.NewLine + "Please close some.", "too many ASPs");
         status("Too many ASPs.  Disabled.");
         debug("Too many ASPs.  Disabled.");
         return;
     }
     else
     {
         status("ASP " + (_ASPINSTANCE+1) + "/" + MAXASPINSTANCE);
         debug("ASP " + (_ASPINSTANCE+1) + "/" + MAXASPINSTANCE);
     }
     // set next response id
     _NEXTRESPONSEID = _ASPINSTANCE * MAXRESPONSEPERASP;
     _INITIALRESPONSEID = _NEXTRESPONSEID;
     _remskin.Click+=new EventHandler(_remskin_Click);
     _saveskins.Click+=new EventHandler(_saveskins_Click);
     _skins.SelectedIndexChanged+=new EventHandler(_skins_SelectedIndexChanged);
     _dw.NewCreateTicketEvent += new DebugDelegate(_dw_NewCreateTicketEvent);
     _ar.GotTick += new TickDelegate(tl_gotTick);
     _ar.GotBadTick += new VoidDelegate(_ar_GotBadTick);
     _ar.GotTickOverrun += new VoidDelegate(_ar_GotTickOverrun);
     string[] servers = Properties.Settings.Default.ServerIpAddresses.Split(',');
     _bf = new BrokerFeed(Properties.Settings.Default.prefquote, Properties.Settings.Default.prefexecute,_ao._providerfallback.Checked,false,PROGRAM,servers,Properties.Settings.Default.ServerPort);
     _bf.VerboseDebugging = Properties.Settings.Default.VerboseDebugging;
     _bf.SendDebugEvent+=new DebugDelegate(debug);
     _rt.PushTracksCloseMax = Properties.Settings.Default.TicketsOnCloseMaxAttempts;
     _rt.PushTracksOnClose = Properties.Settings.Default.TicketsOnClose;
     _rt.TrackEnabled = Properties.Settings.Default.TicketTracking;
     _rt.SendDebug += new DebugDelegate(debug);
     debug(RunTracker.CountNewGetPrettyRuns(PROGRAM,Util.PROGRAM));
     // get providers
     initfeeds();
     // get asp option events
     _ao.MktTimestampChange += new VoidDelegate(_ao_MktTimestampChange);
     _ao.TimeoutChanged += new Int32Delegate(_ao_TimeoutChanged);
     _ao._datasel.SelectionChangeCommitted+= new EventHandler(_prefquot_SelectedIndexChanged);
     _ao._execsel.SelectionChangeCommitted+= new EventHandler(_prefexec_SelectedIndexChanged);
     // setup right click menu
     _resnames.ContextMenu= new ContextMenu();
     _resnames.ContextMenu.Popup += new EventHandler(ContextMenu_Popup);
     _resnames.ContextMenu.MenuItems.Add("remove response", new EventHandler(remresp));
     _resnames.ContextMenu.MenuItems.Add("enabled", new EventHandler(toggleresponse));
     _resnames.ContextMenu.MenuItems.Add("save to skin", new EventHandler(add2skin));
     _resnames.ContextMenu.MenuItems.Add("edit symbols", new EventHandler(editsyms));
     // make sure we exit properly
     this.FormClosing += new FormClosingEventHandler(ASP_FormClosing);
     bw.DoWork += new DoWorkEventHandler(bw_DoWork);
     bw.RunWorkerAsync();
     // handle capital connections on seperate thread
     cc.DoWork += new DoWorkEventHandler(cc_DoWork);
     // write indicator output
     si.DoWork += new DoWorkEventHandler(si_DoWork);
     si.RunWorkerAsync();
     // get last loaded response library
     LoadResponseDLL(Properties.Settings.Default.boxdll);
     // load any skins we can find
     findskins();
     // process command line
     processcommands();
 }