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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            DataSet1.StockQuotesRow row = dataSet1.StockQuotes.NewStockQuotesRow();
            row.Symbol = textBoxStock.Text;
            dataSet1.StockQuotes.AddStockQuotesRow(row);

            StockSubscriptionId subscription = new StockSubscriptionId(row.Symbol, (object)row);

            m_subscriptions.Add(subscription);

            if (m_nativeUtilities.IsConnected)
            {
                m_nativeUtilities.Subscribe(new StockSubscriptionId[] { subscription });
            }
            else if (m_messageUtilities.IsSubscriberStarted)
            {
                m_messageUtilities.Subscribe(subscription.Symbol, QuoteType.Stock, subscription.QuoteObject);
            }
        }