Ejemplo n.º 1
0
 private void showNextValidId(ConnectionStatusMessage obj)
 {
     if (obj.IsConnected)
     {
         IsConnected = true;
     }
 }
Ejemplo n.º 2
0
 private void OnConnectionStatusChanged(ConnectionStatusMessage message)
 {
     if (IsOnline != message.IsOnline)
     {
         _isOnline = message.IsOnline;
         RaisePropertyChanged("IsOnline");
     }
 }
Ejemplo n.º 3
0
 private void OnConnectionStatusChanged(ConnectionStatusMessage obj)
 {
     if (obj.IsOnline)
     {
         SetOnline(obj.UserInitiated);
     }
     else
     {
         SetOffline(obj.UserInitiated);
     }
 }
Ejemplo n.º 4
0
        private void ibClient_NextValidId(ConnectionStatusMessage statusMessage)
        {
            IsConnected = statusMessage.IsConnected;

            if (statusMessage.IsConnected)
            {
                Console.WriteLine("Connected! Your client Id: " + ibClient.ClientId);
            }
            else
            {
                Console.WriteLine("Disconnected...");
            }
        }
Ejemplo n.º 5
0
        private void ibClient_NextValidId(ConnectionStatusMessage statusMessage)
        {
            IsConnected = statusMessage.IsConnected;

            if (statusMessage.IsConnected)
            {
                Console.WriteLine("Connected! Your client Id: " + ibClient.ClientId);
                ORDER_ID = ibClient.NextOrderId;
                Console.WriteLine("Next Order ID: {0}", ORDER_ID);
            }
            else
            {
                Console.WriteLine("Disconnected...");
            }
        }
Ejemplo n.º 6
0
        public void UpdateUI(IBMessage message)
        {
            switch (message.Type)
            {
            case MessageType.ManagedAccounts:
                accountManager.ManageAccounts = ((ManageAccountsMessage)message).ManageAccounts;
                accountList.ItemsSource       = ((ManageAccountsMessage)message).ManageAccounts.ToArray();
                break;

            case MessageType.AccountSummary:
                accountManager.UpdateUI(message);
                break;

            case MessageType.AccountSummaryEnd:
                accountManager.UpdateUI(message);
                break;

            case MessageType.Error:
                ErrorMessage error = (ErrorMessage)message;
                ShowMessageOnPanel(error.ToString());
                break;

            case MessageType.ConnectionStatus:
                ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message;
                if (statusMessage.IsConnected)
                {
                }
                break;

            case MessageType.TickPrice:
                HandleTickMessage((MarketDataMessage)message);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 7
0
        private void UpdateUI(IBMessage message)
        {
            ShowMessageOnPanel("(UpdateUI) Message type: " + message.Type.ToString());

            switch (message.Type)
            {
            case MessageType.ConnectionStatus:
            {
                ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message;
                if (statusMessage.IsConnected)
                {
                    status_CT.Text     = "Connected! Your client Id: " + ibClient.ClientId;
                    connectButton.Text = "Disconnect";
                }
                else
                {
                    status_CT.Text     = "Disconnected...";
                    connectButton.Text = "Connect";
                }
                break;
            }

            case MessageType.Error:
            {
                ErrorMessage error = (ErrorMessage)message;
                ShowMessageOnPanel("Request " + error.RequestId + ", Code: " + error.ErrorCode + " - " + error.Message);
                HandleErrorMessage(error);
                break;
            }

            case MessageType.TickOptionComputation:
            case MessageType.TickPrice:
            case MessageType.TickSize:
            {
                HandleTickMessage((MarketDataMessage)message);
                break;
            }

            case MessageType.MarketDepth:
            case MessageType.MarketDepthL2:
            {
                deepBookManager.UpdateUI(message);
                break;
            }

            case MessageType.HistoricalData:
            case MessageType.HistoricalDataEnd:
            {
                historicalDataManager.UpdateUI(message);
                break;
            }

            case MessageType.RealTimeBars:
            {
                realTimeBarManager.UpdateUI(message);
                break;
            }

            case MessageType.ScannerData:
            case MessageType.ScannerParameters:
            {
                scannerManager.UpdateUI(message);
                break;
            }

            case MessageType.OpenOrder:
            case MessageType.OpenOrderEnd:
            case MessageType.OrderStatus:
            case MessageType.ExecutionData:
            case MessageType.CommissionsReport:
            {
                orderManager.UpdateUI(message);
                break;
            }

            case MessageType.ManagedAccounts:
            {
                orderManager.ManagedAccounts   = ((ManagedAccountsMessage)message).ManagedAccounts;
                accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                exerciseAccount.Items.AddRange(((ManagedAccountsMessage)message).ManagedAccounts.ToArray());
                break;
            }

            case MessageType.AccountSummaryEnd:
            {
                accSummaryRequest.Text = "Request";
                accountManager.UpdateUI(message);
                break;
            }

            case MessageType.AccountDownloadEnd:
            {
                break;
            }

            case MessageType.AccountUpdateTime:
            {
                accUpdatesLastUpdateValue.Text = ((UpdateAccountTimeMessage)message).Timestamp;
                break;
            }

            case MessageType.PortfolioValue:
            {
                accountManager.UpdateUI(message);
                if (exerciseAccount.SelectedItem != null)
                {
                    optionsManager.HandlePosition((UpdatePortfolioMessage)message);
                }
                break;
            }

            case MessageType.AccountSummary:
            case MessageType.AccountValue:
            case MessageType.Position:
            case MessageType.PositionEnd:
            {
                accountManager.UpdateUI(message);
                break;
            }

            case MessageType.ContractDataEnd:
            {
                searchContractDetails.Enabled = true;
                contractManager.UpdateUI(message);

                foreach (var socket in allSockets.ToList())                                 // Loop through all connections/connected clients and send each of them a message
                {
                    socket.Send(searchJsonResponse.Test());
                }

                // Send json object
                // After it is sent .clear it!
                //MessageBox.Show(searchJsonResponse.Test());
                searchJsonResponse.Clear();                                 // Collection empty

                break;
            }

            case MessageType.ContractData:
            {
                HandleContractDataMessage((ContractDetailsMessage)message);
                //MessageBox.Show("contract_start");

                foreach (var socket in allSockets.ToList())                                 // Loop through all connections/connected clients and send each of them a message
                {
                    //var castedMessage = (ContractDetailsMessage)message;
                    //ShowMessageOnPanel("SYMBOL: " + castedMessage.ContractDetails.Summary.Symbol + " successfully found at: " + castedMessage.ContractDetails.Summary.PrimaryExch + " exchange");
                    //socket.Send("SYMBOL: " + castedMessage.ContractDetails.Summary.Symbol + " successfully found at: " + castedMessage.ContractDetails.Summary.Exchange + " exchange");
                }

                // Add new object to json array
                var z = (ContractDetailsMessage)message;                                 // Type cast
                var x = z.ContractDetails.Summary;
                searchJsonResponse.Add(x.Exchange, x.LocalSymbol, x.SecType, x.Currency, x.Exchange, x.PrimaryExch, x.ConId);
                //Log.Insert(DateTime.Now, "Form1.cs", string.Format("ContractData: {0} {1} {2} {3} {4} {5} {6}", x.Exchange, x.LocalSymbol, x.SecType, x.Currency, x.Exchange, x.PrimaryExch, x.ConId), "white");

                break;
            }

            case MessageType.FundamentalData:
            {
                fundamentalsQueryButton.Enabled = true;
                contractManager.UpdateUI(message);
                break;
            }

            case MessageType.ReceiveFA:
            {
                advisorManager.UpdateUI((AdvisorDataMessage)message);
                break;
            }

            case MessageType.PositionMulti:
            case MessageType.AccountUpdateMulti:
            case MessageType.PositionMultiEnd:
            case MessageType.AccountUpdateMultiEnd:
            {
                acctPosMultiManager.UpdateUI(message);
                break;
            }

            case MessageType.SecurityDefinitionOptionParameter:
            case MessageType.SecurityDefinitionOptionParameterEnd:
            {
                optionsManager.UpdateUI(message);
                break;
            }

            case MessageType.SoftDollarTiers:
            {
                orderManager.UpdateUI(message);
                break;
            }

            default:
            {
                HandleMessage(new ErrorMessage(-1, -1, message.ToString()));
                break;
            }
            }
        }         // private void UpdateUI
Ejemplo n.º 8
0
        private void UpdateUI(IBMessage message)
        {
            switch (message.Type)
            {
            case MessageType.ConnectionStatus:
            {
                ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message;
                if (statusMessage.IsConnected)
                {
                    status_CT.Text     = "Connected! Your client Id: " + ibClient.ClientId;
                    connectButton.Text = "Disconnect";
                }
                else
                {
                    status_CT.Text     = "Disconnected...";
                    connectButton.Text = "Connect";
                }
                break;
            }

            case MessageType.Error:
            {
                ErrorMessage error = (ErrorMessage)message;
                ShowMessageOnPanel("Request " + error.RequestId + ", Code: " + error.ErrorCode + " - " + error.Message + "\r\n");
                break;
            }

            case MessageType.TickOptionComputation:
            case MessageType.TickPrice:
            case MessageType.TickSize:
            {
                HandleTickMessage((MarketDataMessage)message);
                break;
            }

            case MessageType.MarketDepth:
            case MessageType.MarketDepthL2:
            {
                deepBookManager.UpdateUI(message);
                break;
            }

            case MessageType.HistoricalData:
            case MessageType.HistoricalDataEnd:
            {
                historicalDataManager.UpdateUI(message);
                break;
            }

            case MessageType.RealTimeBars:
            {
                realTimeBarManager.UpdateUI(message);
                break;
            }

            case MessageType.ScannerData:
            {
                scannerManager.UpdateUI(message);
                break;
            }

            case MessageType.OpenOrder:
            case MessageType.OpenOrderEnd:
            case MessageType.OrderStatus:
            case MessageType.ExecutionData:
            case MessageType.CommissionsReport:
            {
                orderManager.UpdateUI(message);
                break;
            }

            case MessageType.ManagedAccounts:
            {
                orderManager.ManagedAccounts   = ((ManagedAccountsMessage)message).ManagedAccounts;
                accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                exerciseAccount.Items.AddRange(((ManagedAccountsMessage)message).ManagedAccounts.ToArray());
                break;
            }

            case MessageType.AccountSummaryEnd:
            {
                accSummaryRequest.Text = "Request";
                accountManager.UpdateUI(message);
                break;
            }

            case MessageType.AccountDownloadEnd:
            {
                break;
            }

            case MessageType.AccountUpdateTime:
            {
                accUpdatesLastUpdateValue.Text = ((UpdateAccountTimeMessage)message).Timestamp;
                break;
            }

            case MessageType.PortfolioValue:
            {
                accountManager.UpdateUI(message);
                if (exerciseAccount.SelectedItem != null)
                {
                    optionsManager.HandlePosition((UpdatePortfolioMessage)message);
                }
                break;
            }

            case MessageType.AccountSummary:
            case MessageType.AccountValue:
            case MessageType.Position:
            case MessageType.PositionEnd:
            {
                accountManager.UpdateUI(message);
                break;
            }

            case MessageType.ContractDataEnd:
            {
                searchContractDetails.Enabled = true;
                contractManager.UpdateUI(message);
                break;
            }

            case MessageType.ContractData:
            {
                HandleContractDataMessage((ContractDetailsMessage)message);
                break;
            }

            case MessageType.FundamentalData:
            {
                fundamentalsQueryButton.Enabled = true;
                contractManager.UpdateUI(message);
                break;
            }

            case MessageType.ReceiveFA:
            {
                advisorManager.UpdateUI((AdvisorDataMessage)message);
                break;
            }

            default:
            {
                HandleMessage(new ErrorMessage(-1, -1, message.ToString()));
                break;
            }
            }
        }
Ejemplo n.º 9
0
        private void UpdateUI(IBMessage message)
        {
            // http://nlog-project.org/download/ Logging lib

            // These messages are generated for evry event. Uncomment to see what type of messages are comeing. Importand for debugging
            ListViewLogging.log_add(this, "messageTypeListBox", "Form1.cs", message.Type.ToString(), "white");             // Output to the separate listView

            switch (message.Type)
            {
            case MessageType.ConnectionStatus:
            {
                ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message;

                ShowMessageOnPanel("Connection status: " + statusMessage.IsConnected);

                if (statusMessage.IsConnected)
                {
                    status_CT.Text = "Connected";
                    button13.Text  = "Disconnect";
                }
                else
                {
                    status_CT.Text = "Disconnected...";
                    button13.Text  = "Connect";
                }
                break;
            }

            case MessageType.Error:
            {
                ErrorMessage error = (ErrorMessage)message;
                ShowMessageOnPanel("ERROR. Request " + error.RequestId + ", Code: " + error.ErrorCode + " - " + error.Message);
                HandleErrorMessage(error);
                break;
            }

            case MessageType.TickOptionComputation:
            case MessageType.TickPrice:
            case MessageType.TickSize:
            {
                //HandleTickMessage((MarketDataMessage)message);
                break;
            }

            case MessageType.MarketDepth:
            case MessageType.MarketDepthL2:
            {
                //deepBookManager.UpdateUI(message);
                break;
            }

            case MessageType.HistoricalData:
            case MessageType.HistoricalDataEnd:
            {
                //historicalDataManager.UpdateUI(message);
                break;
            }

            case MessageType.RealTimeBars:
            {
                //realTimeBarManager.UpdateUI(message);
                break;
            }

            case MessageType.ScannerData:
            case MessageType.ScannerParameters:
            {
                //scannerManager.UpdateUI(message);
                break;
            }

            case MessageType.OpenOrder:
            {
                var castedMessage = (OpenOrderMessage)message;
                ShowMessageOnPanel("OpenOrder. Contract: " + castedMessage.Contract + " Order: " + castedMessage.Order + " OrderID: " + castedMessage.OrderId + " OrderState: " + castedMessage.OrderState + " Type:" + castedMessage.Type);
                break;
            }

            case MessageType.OrderStatus:
            {
                var castedMessage = (OrderStatusMessage)message;
                ShowMessageOnPanel("OrderStatus. AvgFillPrice: " + castedMessage.AvgFillPrice + " ClientId: " + castedMessage.ClientId + " Filled: " + castedMessage.Filled + " LastFillPrice: " + castedMessage.LastFillPrice + " OrderId:" + castedMessage.OrderId + " ParentID:" + castedMessage.ParentId + " PermID:" + castedMessage.PermId + " Remaining:" + castedMessage.Remaining + " Status:" + castedMessage.Status + " Type:" + castedMessage.Type + " WhyHwld:" + castedMessage.WhyHeld);
                break;
            }


            case MessageType.OpenOrderEnd:
            case MessageType.ExecutionData:
            case MessageType.CommissionsReport:
            {
                //orderManager.UpdateUI(message); ********************************************************
                placeOrder.UpdateUI(message);
                break;
            }

            case MessageType.ManagedAccounts:
            {
                MessageBox.Show("case MessageType.ManagedAccounts: no message");
                //orderManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                //accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                //exerciseAccount.Items.AddRange(((ManagedAccountsMessage)message).ManagedAccounts.ToArray());
                break;
            }

            case MessageType.AccountSummaryEnd:
            {
                //accSummaryRequest.Text = "Request";
                //accountManager.UpdateUI(message);
                break;
            }

            case MessageType.AccountDownloadEnd:
            {
                break;
            }

            case MessageType.AccountUpdateTime:
            {
                //accUpdatesLastUpdateValue.Text = ((UpdateAccountTimeMessage)message).Timestamp;
                break;
            }

            case MessageType.PortfolioValue:
            {
                //accountManager.UpdateUI(message);
                //if (exerciseAccount.SelectedItem != null)
                //	optionsManager.HandlePosition((UpdatePortfolioMessage)message);
                break;
            }

            case MessageType.AccountSummary:
            case MessageType.AccountValue:
            case MessageType.Position:
            case MessageType.PositionEnd:
            {
                //accountManager.UpdateUI(message);
                break;
            }

            case MessageType.ContractDataEnd:                     // This event occur after symbol search
            {
                //searchContractDetails.Enabled = true;
                //contractManager.UpdateUI(message);

                break;
            }

            case MessageType.ContractData:                     // This event occur after symbol search
            {
                //HandleContractDataMessage((ContractDetailsMessage)message); // Type cast
                var castedMessage = (ContractDetailsMessage)message;
                ShowMessageOnPanel("SYMBOL: " + castedMessage.ContractDetails.Summary.Symbol + " successfully found at: " + castedMessage.ContractDetails.Summary.PrimaryExch + " exchange");
                break;
            }

            case MessageType.FundamentalData:
            {
                //fundamentalsQueryButton.Enabled = true;
                //contractManager.UpdateUI(message);
                break;
            }

            case MessageType.ReceiveFA:
            {
                //advisorManager.UpdateUI((AdvisorDataMessage)message);
                break;
            }

            case MessageType.PositionMulti:
            case MessageType.AccountUpdateMulti:
            case MessageType.PositionMultiEnd:
            case MessageType.AccountUpdateMultiEnd:
            {
                //acctPosMultiManager.UpdateUI(message);
                break;
            }

            case MessageType.SecurityDefinitionOptionParameter:
            case MessageType.SecurityDefinitionOptionParameterEnd:
            {
                //optionsManager.UpdateUI(message);
                break;
            }

            case MessageType.SoftDollarTiers:
            {
                //orderManager.UpdateUI(message);
                placeOrder.UpdateUI(message);
                var castedMessage = (ExecutionMessage)message;
                ListViewLogging.log_add(this, "brokerListBox", "case MessageType.SoftDollarTiers:", castedMessage.ToString(), "yellow");
                // ("PlaceOrder.cs private void HandleExecutionMessage(ExecutionMessage message): " + message.Execution.OrderId + " orderRef: " + message.Execution.OrderRef + " price: " + message.Execution.Price + " time: " + message.Execution.Time + " accountNumber" + message.Execution.AcctNumber);
                break;
            }

            default:
            {
                HandleMessage(new ErrorMessage(-1, -1, message.ToString()));
                break;
            }
            }
        }
Ejemplo n.º 10
0
        private void UpdateUI(IBMessage message)
        {
            switch (message.Type)
            {
            case MessageType.ConnectionStatus:
            {
                ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message;
                if (statusMessage.IsConnected)
                {
                    btn_connect_light.BackColor = Color.LightGreen;
                    btn_connect_light.Text      = "ON";
                    accountManager.RequestAccountSummary();

                    grid_order_summary.Rows.Clear();
                    ibClient.ClientSocket.reqExecutions(1, new ExecutionFilter());
                    ibClient.ClientSocket.reqCurrentTime();
                    //grid_open_order.Rows.Clear();
                    //ibClient.ClientSocket.reqAllOpenOrders();
                }
                else
                {
                    btn_connect_light.BackColor = Color.Red;
                    btn_connect_light.Text      = "OFF";
                }
                break;
            }

            case MessageType.ManagedAccounts:
            {
                accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                accountManager.SubscribeAccountUpdates();
                break;
            }

            case MessageType.AccountValue:
            {
                accountManager.UpdateUI(message);
                break;
            }

            case MessageType.TickOptionComputation:
            case MessageType.TickPrice:
            case MessageType.TickSize:
            {
                HandleTickMessage((MarketDataMessage)message);
                break;
            }

            case MessageType.RealTimeBars:
            {
                realTimeBarManager.UpdateUI(message);
                break;
            }

            case MessageType.HistoricalData:
            case MessageType.HistoricalDataEnd:
            {
                IAppMDManager appMDMManager = appStrategyManager.getAppMDManager();
                //2015-10-27
                if (isHistDataRequested(message))
                {
                    appMDMManager.updateHistDataAdHoc((HistoricalDataMessage)message);
                }
                else
                {
                    historicalDataManager.UpdateUI(message);
                }

                //historicalDataManager.UpdateUI(message);
                break;
            }

            case MessageType.PortfolioValue:
            {
                accountManager.UpdateUI(message);
                break;
            }

            case MessageType.OpenOrder:
            case MessageType.OpenOrderEnd:
            case MessageType.OrderStatus:
            case MessageType.ExecutionData:
            case MessageType.CommissionsReport:
            {
                if (message.Type == MessageType.ExecutionData)
                {
                    orderManager.processExecution((ExecutionMessage)message);
                }
                //HandleExecutionMessage((ExecutionMessage)message);

                orderManager.UpdateUI(message);
                break;
            }

            case MessageType.ServerTime:
            {
                ServerTimeMessage tm = (ServerTimeMessage)message;
                appStrategyManager.calculateTimeDiffServer(tm.Time);
                //strategyManager.calculateTimeDiffServer(tm.Time);
                break;
            }

            case MessageType.Error:
            {
                ErrorMessage error = (ErrorMessage)message;
                ShowMessageOnPanel("Request " + error.RequestId + ", Code: " + error.ErrorCode + " - " + error.Message + "\r\n");
                HandleErrorMessage(error);
                break;
            }
            }
        }
Ejemplo n.º 11
0
        private void UpdateUI(IBMessage message)
        {
            switch (message.Type)
            {
            case MessageType.ConnectionStatus:
            {
                ConnectionStatusMessage status = (ConnectionStatusMessage)message;
                if (status.Connected)
                {
                    tssLabel.Text   = "Status: Connected - Client ID = " + Client.ClientId;
                    btnConnect.Text = "Disconnect";

                    //OneDayWPRTimer = new Timer(new TimerCallback(CalculateWPR), WPRType.OneDay, 0, 60 * 1000);
                    //FiveDayWPRTimer = new Timer(new TimerCallback(CalculateWPR), WPRType.FiveDay, 0, 60 * 1000);
                    //WPRTimer = new Timer(new TimerCallback(CalculateWPR), WPRType.Both, 0, 60 * 1000);
                }
                else
                {
                    tssLabel.Text   = "Status: Disconnected";
                    btnConnect.Text = "Connect";
                }
                break;
            }

            case MessageType.Error:
            {
                ErrorMessage error     = (ErrorMessage)message;
                string       requestId = GetString(error.RequestId, "RequestId");
                string       code      = GetString(error.Code, "Code");
                Log($"{(string.IsNullOrEmpty(requestId) ? string.Empty : requestId + ", ")}" +
                    $"{(string.IsNullOrEmpty(code) ? string.Empty : code + " - ")}" +
                    $"{error.Message}");
                break;
            }

            case MessageType.Log:
            {
                LogMessage log = (LogMessage)message;
                Log(log.Message);
                break;
            }

            case MessageType.CalculateWPR:
            {
                //Log(string.Format("{0:MM/dd/yyyy HH:mm:ss} - Calculate WPR", DateTime.Now));
                MDManager.UpdateUI(message);
                break;
            }

            case MessageType.TickPrice:
            {
                MDManager.UpdateUI(message);
                break;
            }

            case MessageType.HistoricalDataEnd:
            {
                HistoricalDataEndMessage historicalDataEndMessage = (HistoricalDataEndMessage)message;
                HandleMessage(new LogMessage(historicalDataEndMessage.ToString()));
                MDManager.UpdateHistoricalData(message);
                break;
            }

            case MessageType.HistoricalData:
            {
                HistoricalDataMessage historicalDataMessage = (HistoricalDataMessage)message;
                HandleMessage(new LogMessage(historicalDataMessage.ToString()));
                MDManager.UpdateHistoricalData(message);
                break;
            }

            case MessageType.RealTimeBars:
            {
                RealTimeBarMessage rtbMessage = (RealTimeBarMessage)message;
                HandleMessage(new LogMessage(rtbMessage.ToString()));
                MDManager.UpdateRealTimeData(rtbMessage);
                break;
            }
            //case MessageType.ScannerData:
            //case MessageType.ScannerParameters:
            //	{
            //		scannerManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.OpenOrder:
            //case MessageType.OpenOrderEnd:
            //case MessageType.OrderStatus:
            //case MessageType.ExecutionData:
            //case MessageType.CommissionsReport:
            //	{
            //		orderManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.ManagedAccounts:
            //	{
            //		orderManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
            //		accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
            //		exerciseAccount.Items.AddRange(((ManagedAccountsMessage)message).ManagedAccounts.ToArray());
            //		break;
            //	}
            //case MessageType.AccountSummaryEnd:
            //	{
            //		accSummaryRequest.Text = "Request";
            //		accountManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.AccountDownloadEnd:
            //	{
            //		break;
            //	}
            //case MessageType.AccountUpdateTime:
            //	{
            //		accUpdatesLastUpdateValue.Text = ((UpdateAccountTimeMessage)message).Timestamp;
            //		break;
            //	}
            //case MessageType.PortfolioValue:
            //	{
            //		accountManager.UpdateUI(message);
            //		if (exerciseAccount.SelectedItem != null)
            //			optionsManager.HandlePosition((UpdatePortfolioMessage)message);
            //		break;
            //	}
            //case MessageType.AccountSummary:
            //case MessageType.AccountValue:
            //case MessageType.Position:
            //case MessageType.PositionEnd:
            //	{
            //		accountManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.ContractDataEnd:
            //	{
            //		searchContractDetails.Enabled = true;
            //		contractManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.ContractData:
            //	{
            //		HandleContractDataMessage((ContractDetailsMessage)message);
            //		break;
            //	}
            //case MessageType.FundamentalData:
            //	{
            //		fundamentalsQueryButton.Enabled = true;
            //		contractManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.ReceiveFA:
            //	{
            //		advisorManager.UpdateUI((AdvisorDataMessage)message);
            //		break;
            //	}
            //case MessageType.PositionMulti:
            //case MessageType.AccountUpdateMulti:
            //case MessageType.PositionMultiEnd:
            //case MessageType.AccountUpdateMultiEnd:
            //	{
            //		acctPosMultiManager.UpdateUI(message);
            //		break;
            //	}

            //case MessageType.SecurityDefinitionOptionParameter:
            //case MessageType.SecurityDefinitionOptionParameterEnd:
            //	{
            //		optionsManager.UpdateUI(message);
            //		break;
            //	}
            //case MessageType.SoftDollarTiers:
            //	{
            //		orderManager.UpdateUI(message);
            //		break;
            //	}

            default:
            {
                HandleMessage(new ErrorMessage(message.ToString()));
                break;
            }
            }
        }
Ejemplo n.º 12
0
 private void HandleMessage(ConnectionStatusMessage m)
 {
     this.IsConnected = m.IsConnected;
     Framework.Log(this, "Connected to IBGateway:" + m.IsConnected);
 }
Ejemplo n.º 13
0
 private void ibClient_UpdateConnectionStatus(ConnectionStatusMessage statusMessage)
 {
     IsConnected = statusMessage.IsConnected;
 }
Ejemplo n.º 14
0
 private void ClientOnNextValidId(ConnectionStatusMessage obj)
 {
     Console.WriteLine($"Next Valid Id: {client.NextOrderId}");
     NextOrderId = client.NextOrderId;
 }
Ejemplo n.º 15
0
        private void UpdateUI(IBMessage message)
        {
            // http://nlog-project.org/download/ A logging lib
            ShowMessageOnPanel("(UpdateUI) Message type: " + message.Type.ToString());

            switch (message.Type)
            {
            case MessageType.ConnectionStatus:
            {
                ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message;
                if (statusMessage.IsConnected)
                {
                    status_CT.Text = "Connected! Your client Id: " + ibClient.ClientId;
                    button1.Text   = "Disconnect";
                }
                else
                {
                    status_CT.Text = "Disconnected...";
                    button1.Text   = "Connect";
                }
                break;
            }

            case MessageType.Error:
            {
                ErrorMessage error = (ErrorMessage)message;
                ShowMessageOnPanel("Request " + error.RequestId + ", Code: " + error.ErrorCode + " - " + error.Message);
                HandleErrorMessage(error);
                break;
            }

            case MessageType.TickOptionComputation:
            case MessageType.TickPrice:
            case MessageType.TickSize:
            {
                //HandleTickMessage((MarketDataMessage)message);
                break;
            }

            case MessageType.MarketDepth:
            case MessageType.MarketDepthL2:
            {
                //deepBookManager.UpdateUI(message);
                break;
            }

            case MessageType.HistoricalData:
            case MessageType.HistoricalDataEnd:
            {
                //historicalDataManager.UpdateUI(message);
                break;
            }

            case MessageType.RealTimeBars:
            {
                //realTimeBarManager.UpdateUI(message);
                break;
            }

            case MessageType.ScannerData:
            case MessageType.ScannerParameters:
            {
                //scannerManager.UpdateUI(message);
                break;
            }

            case MessageType.OpenOrder:
            case MessageType.OpenOrderEnd:
            case MessageType.OrderStatus:
            case MessageType.ExecutionData:
            case MessageType.CommissionsReport:
            {
                //orderManager.UpdateUI(message);
                break;
            }

            case MessageType.ManagedAccounts:
            {
                //orderManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                //accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts;
                //exerciseAccount.Items.AddRange(((ManagedAccountsMessage)message).ManagedAccounts.ToArray());
                break;
            }

            case MessageType.AccountSummaryEnd:
            {
                //accSummaryRequest.Text = "Request";
                //accountManager.UpdateUI(message);
                break;
            }

            case MessageType.AccountDownloadEnd:
            {
                break;
            }

            case MessageType.AccountUpdateTime:
            {
                //accUpdatesLastUpdateValue.Text = ((UpdateAccountTimeMessage)message).Timestamp;
                break;
            }

            case MessageType.PortfolioValue:
            {
                //accountManager.UpdateUI(message);
                //if (exerciseAccount.SelectedItem != null)
                //	optionsManager.HandlePosition((UpdatePortfolioMessage)message);
                break;
            }

            case MessageType.AccountSummary:
            case MessageType.AccountValue:
            case MessageType.Position:
            case MessageType.PositionEnd:
            {
                //accountManager.UpdateUI(message);
                break;
            }

            case MessageType.ContractDataEnd:
            {
                //searchContractDetails.Enabled = true;
                contractManager.UpdateUI(message);
                break;
            }

            case MessageType.ContractData:
            {
                HandleContractDataMessage((ContractDetailsMessage)message);                                 // ***********************
                var z = (ContractDetailsMessage)message;
                ShowMessageOnPanel("SYMBOL: " + z.ContractDetails.Summary.Symbol + " successfully found at: " + z.ContractDetails.Summary.PrimaryExch + " exchange");
                break;
            }

            case MessageType.FundamentalData:
            {
                //fundamentalsQueryButton.Enabled = true;
                contractManager.UpdateUI(message);
                break;
            }

            case MessageType.ReceiveFA:
            {
                //advisorManager.UpdateUI((AdvisorDataMessage)message);
                break;
            }

            case MessageType.PositionMulti:
            case MessageType.AccountUpdateMulti:
            case MessageType.PositionMultiEnd:
            case MessageType.AccountUpdateMultiEnd:
            {
                //acctPosMultiManager.UpdateUI(message);
                break;
            }

            case MessageType.SecurityDefinitionOptionParameter:
            case MessageType.SecurityDefinitionOptionParameterEnd:
            {
                //optionsManager.UpdateUI(message);
                break;
            }

            case MessageType.SoftDollarTiers:
            {
                //orderManager.UpdateUI(message);
                break;
            }

            default:
            {
                HandleMessage(new ErrorMessage(-1, -1, message.ToString()));                                 // Default message
                break;
            }
            }
        }