Ejemplo n.º 1
0
        private void StartApplication()
        {
            try
            {
                _appManager       = new AppManager();
                _uiMessageHandler = new UIMessageHandler();
                _uiMessageHandler.Start();
                _uiMessageHandler.APIMessageArrive += DistributerOnAPIMessageArrive;
                _uiMessageHandler.ExceptionThrown  += DistributerOnExceptionThrown;

                _appManager.Distributer.AddUIMessageHandler(_uiMessageHandler);

                UIDataBroker = new UIDataBroker();
                UIDataBroker.Start();
                _appManager.Distributer.AddUIDataBroker(UIDataBroker);

                _appManager.ConnectToBroker();
                //For Test: Thread.Sleep(30000);
                _startApplicationMethodDone = true;
                this.InvokeIfRequired(() =>
                {
                    PopupMessageForm.ShowMessage("Start Application Method finish successfully!!!", Color.Green,
                                                 this, 5, withSiren: false);
                    UpdateGuiComponents();
                });
                _appManager.PositionNeedToOptimized += AppManagerOnPositionNeedToOptimized;
                _appManager.TWSDisconnected         += AppManagerOnTWSDisconnected;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                this.InvokeIfRequired(() => { MessageBox.Show(ex.Message); });
            }
        }
Ejemplo n.º 2
0
 private void AppManagerOnTWSDisconnected()
 {
     this.InvokeIfRequired(() =>
     {
         PopupMessageForm.ShowMessage("DisonnectFromBroker called. We are disconnected from TWS!",
                                      Color.Red, this, 15);
     });
 }
Ejemplo n.º 3
0
 private void DistributerOnExceptionThrown(ExceptionData exceptionData)
 {
     if (!(exceptionData.ThrownException is SocketException))
     {
         return;
     }
     this.InvokeIfRequired(() =>
     {
         PopupMessageForm.ShowMessage(exceptionData.ToString(), Color.Red, this, 5, withSiren: true);
     });
 }
Ejemplo n.º 4
0
 private void AppManagerOnPositionNeedToOptimized(string msg)
 {
     if (cbxShowPopUpMessages.Checked == false)
     {
         return;
     }
     this.InvokeIfRequired(() =>
     {
         PopupMessageForm.ShowMessage(msg,
                                      Color.Orange, this, 15);
     });
 }
Ejemplo n.º 5
0
 private void MainForm_Load(object sender, System.EventArgs e)
 {
     Logger.Info("Start RoboTrader - Main Form");
     GeneralTimer.GeneralTimerInstance.AddTask(TimeSpan.FromMilliseconds(1), StartApplication, false);
     GeneralTimer.GeneralTimerInstance.AddTask(TimeSpan.FromSeconds(30),
                                               () =>
     {
         if (_startApplicationMethodDone == false)
         {
             this.InvokeIfRequired(() =>
             {
                 PopupMessageForm.ShowMessage("Start Application Method fail, Time out 30 sec!!!!!!",
                                              Color.Red, ParentForm, 5, withSiren: true);
             });
         }
     }, false);
 }