/// <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"); } }
/// <summary> /// Overloaded constructor /// </summary> /// <param name="searchResult">The downloaded search result with the values</param> /// <remarks></remarks> public YIndexID(IDSearchData searchResult) : base(searchResult) { if (!(searchResult.Type == SecurityType.Index)) { throw new ArgumentException("The passed result is not an index", "result"); } }
/// <summary> /// Proves if a search result represents an index /// </summary> /// <param name="result"></param> /// <returns></returns> /// <remarks></remarks> public static bool IsValidSearchResult(IDSearchData result) { return(result.Type == SecurityType.Index); }
/// <summary> /// Proves if a search result represents an index /// </summary> /// <param name="result"></param> /// <returns></returns> /// <remarks></remarks> public static bool IsValidSearchResult(IDSearchData result) { return result.Type == SecurityType.Index; }
/// <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"); } }