Пример #1
0
        public void UpdateUI(SymbolSamplesMessage dataMessage)
        {
            if (!uiControl.Visible)
            {
                uiControl.Visible = true;
            }

            ((DataGridView)uiControl).Rows.Clear();

            if (dataMessage.ReqId == activeReqId)
            {
                DataGridView grid  = (DataGridView)uiControl;
                int          count = 0;
                foreach (ContractDescription cd in dataMessage.ContractDescriptions)
                {
                    grid.Rows.Add();
                    grid[0, count].Value = cd.Contract.ConId;
                    grid[1, count].Value = cd.Contract.Symbol;
                    grid[2, count].Value = cd.Contract.SecType;
                    grid[3, count].Value = cd.Contract.PrimaryExch;
                    grid[4, count].Value = cd.Contract.Currency;
                    foreach (string s in cd.DerivativeSecTypes)
                    {
                        grid[5, count].Value += (s + " ");
                    }
                    count++;
                }
            }
        }
Пример #2
0
        //private static SymbolManager _symbolManager;
        //private static readonly object lockObject = new object();

        //SymbolManager() { }

        ///// <summary>
        ///// Instance
        ///// </summary>
        //public static SymbolManager Instance
        //{
        //    get
        //    {
        //        lock (lockObject)
        //        {
        //            if (_symbolManager == null)
        //            {
        //                _symbolManager = new SymbolManager();
        //            }
        //            return _symbolManager;
        //        }
        //    }
        //}

        /// <summary>
        /// FilterSymbols
        /// </summary>
        /// <param name="company">
        /// </param>
        /// <param name="symbolSamplesMessage">
        /// </param>
        /// <param name="exchangeAndCurrency">
        /// Symbol and currency symbol divided by whitespace.
        /// </param>
        /// <returns></returns>
        public static List <Contract> FilterSymbols(string company, SymbolSamplesMessage symbolSamplesMessage, string exchangeAndCurrency)
        {
            List <Contract> resultArray = new List <Contract>();

            if (string.IsNullOrWhiteSpace(exchangeAndCurrency))
            {
                return(resultArray);
            }

            string[] exchangeAndCurrencyArray = exchangeAndCurrency.Split(" ");
            string   exchange = exchangeAndCurrencyArray[0];
            string   currency = exchangeAndCurrencyArray[1];

            foreach (var contractDescription in symbolSamplesMessage.ContractDescriptions)
            {
                if (contractDescription.Contract.PrimaryExch == exchange && contractDescription.Contract.Currency == currency)
                {
                    resultArray.Add(new Contract {
                        Company  = company,
                        SecType  = contractDescription.Contract.SecType,
                        Symbol   = contractDescription.Contract.Symbol,
                        Currency = contractDescription.Contract.Currency,
                        Exchange = contractDescription.Contract.PrimaryExch,
                    });
                }
            }

            return(resultArray);
        }