Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance from an IDSearchResult
        /// </summary>
        /// <param name="searchResult"></param>
        /// <remarks></remarks>
        public YID(IDSearchData searchResult)
        {
            if (searchResult != null)
            {
                this.SetID(searchResult.ID, false);
                this.Name     = searchResult.Name;
                this.Industry = searchResult.Industry;
                this.Type     = searchResult.Type;

                string exc = searchResult.Exchange.Replace("N/A", "").Trim();
                if (exc != string.Empty)
                {
                    StockExchange se = WorldMarket.GetStockExchangeByID(exc);
                    if (se == null)
                    {
                        se = WorldMarket.GetStockExchangeByName(exc);
                    }
                    if (se != null)
                    {
                        this.StockExchange = se;
                    }
                    else
                    {
                        se = WorldMarket.GetStockExchangeBySuffix(this.ID);
                        if (se != null)
                        {
                            this.StockExchange = se;
                        }
                        else
                        {
                            CountryInfo     cnt = WorldMarket.GetDefaultCountry(Country.US);
                            TradingTimeInfo tti = new TradingTimeInfo(0, new DayOfWeek[] {
                                DayOfWeek.Monday,
                                DayOfWeek.Tuesday,
                                DayOfWeek.Wednesday,
                                DayOfWeek.Thursday,
                                DayOfWeek.Friday
                            }, null, new DateTime(), new TimeSpan(23, 59, 59), -5);
                            this.StockExchange = new StockExchange(searchResult.Exchange, this.Suffix, searchResult.Exchange, cnt, tti);
                        }
                    }
                }

                if (searchResult.ISIN != null && searchResult.ISIN.Value.Replace("N/A", "").Trim() != string.Empty)
                {
                    try
                    {
                        this.ISIN = new ISIN(searchResult.ISIN.Value);
                    }
                    catch (ArgumentException ex)
                    {
                        this.ISIN = null;
                    }
                }
            }
            else
            {
                throw new ArgumentException("The passed result is null", "searchResult");
            }
        }
Ejemplo n.º 2
0
 protected virtual void SetID(string id, bool setStockExchangeBySuffix = true)
 {
     if (id == null || id.Trim() == string.Empty)
     {
         throw new ArgumentNullException("id", "The ID is null.");
     }
     mID = id.Trim().ToUpper();
     this.OnPropertyChanged("ID");
     if (setStockExchangeBySuffix)
     {
         mStockExchange = null;
         StockExchange se = WorldMarket.GetStockExchangeBySuffix(id);
         if (se != null)
         {
             this.StockExchange = se;
         }
     }
 }