private void buttonStart_Click(object sender, EventArgs e) { try { radioButtonTCPBloomberg.Enabled = radioButtonNativeBloomberg.Enabled = false; if (radioButtonNativeBloomberg.Checked) { if (m_nativeUtilities.Init()) { if (m_nativeUtilities.Connect()) { if (m_subscriptions.Count > 0) { m_nativeUtilities.Subscribe(m_subscriptions.ToArray()); } } } } else if (radioButtonTCPBloomberg.Checked) { if (m_messageUtilities.StartSubscriber(Properties.Settings.Default.BloombergHost, Properties.Settings.Default.Port)) { foreach (SubscriptionId id in m_subscriptions) { m_messageUtilities.Subscribe(id.Symbol, (QuoteType)Enum.Parse(typeof(QuoteType), id.CorrelationType, true), id.QuoteObject); } } } else { if (m_messageUtilities.StartSubscriber(Properties.Settings.Default.TWSHost, Properties.Settings.Default.Port)) { foreach (SubscriptionId id in m_subscriptions) { m_messageUtilities.Subscribe(id.Symbol, (QuoteType)Enum.Parse(typeof(QuoteType), id.CorrelationType, true), id.QuoteObject); } } } } catch (Exception ex) { OnError("Error in start processing", ex); } finally { EnableControls(); } }
public bool StartSubscriber() { try { lock (m_quoteServerLock) { if (!IsSubscribed) { // start two subscribers - one for positions and one for indices (necessary in case there is an overlap) IsSubscribed = m_messageUtilities1.StartSubscriber(m_monitorUtilities.QuoteServerHost, m_monitorUtilities.QuoteServerPort) && m_messageUtilities2.StartSubscriber(m_monitorUtilities.QuoteServerHost, m_monitorUtilities.QuoteServerPort); if (IsSubscribed) { QuoteServiceStoppedTime = null; int rowCount; lock (m_portfolioLock) { rowCount = 0; foreach (HugoDataSet.PortfolioRow row in m_portfolio.Rows) { if (!row.IsCurrent_PositionNull()) { int sodPosition = row.IsSOD_PositionNull() ? 0 : row.SOD_Position; if ((row.Current_Position != 0) || (sodPosition != 0) || (row.IsStock == 1)) { row.SubscriptionStatus = SubscriptionStatus.Subscribed.ToString(); m_messageUtilities1.Subscribe(row.Symbol, row.QuoteType, row); rowCount++; } } } PositionMonitorUtilities.Info(String.Format("{0} subscribed to {1} position symbols, host={2}", Name, rowCount, m_monitorUtilities.QuoteServerHost)); rowCount = 0; foreach (HugoDataSet.IndicesRow row in m_indices.Rows) { QuoteType quoteType = row.IndexFlag ? QuoteType.Index : QuoteType.Stock; row.SubscriptionStatus = SubscriptionStatus.Subscribed.ToString(); m_messageUtilities2.Subscribe(row.Symbol, quoteType, row); rowCount++; } PositionMonitorUtilities.Info(String.Format("{0} subscribed to {1} index symbols, host={2}", Name, rowCount, m_monitorUtilities.QuoteServerHost)); } } } } } catch (Exception ex) { PositionMonitorUtilities.Error(Name + " unable to subscribe to market data", ex); StopSubscriber(); } return(IsSubscribed); }
public bool StartSubscriber() { try { if (!IsSubscribed) { int rowCount = 0; if (IsSubscribed = m_messageUtilities.StartSubscriber(Properties.Settings.Default.MarketDataHost, Properties.Settings.Default.MarketDataPort)) { lock (m_portfolioLock) { foreach (HugoDataSet.PortfolioRow row in m_portfolio.Rows) { if (!row.IsCurrent_PositionNull()) { if (row.Current_Position != 0) { row.SubscriptionStatus = SubscriptionStatus.Subscribed.ToString(); m_messageUtilities.Subscribe(row.Symbol, row.QuoteType, row); rowCount++; } } } } } PositionMonitorUtilities.Info(String.Format("{0} subscribed to {1} symbols", Name, rowCount)); } } catch (Exception ex) { PositionMonitorUtilities.Error(Name + " unable to subscribe to market data", ex); StopSubscriber(); } return(IsSubscribed); }