lookupsecurities. StockSharphttps://stocksharp.com/handlers/atom.ashx?category=tag&id=lookupsecurities&type=communityCopyright @ StockSharp Platform LLC 2010 - 20242024-03-29T10:06:35Zhttps://stocksharp.com/images/logo.pnghttps://stocksharp.com/topic/8770/Problems with lookup of security2017-10-30T22:07:51Z2017-10-31T22:39:52ZJohan Kirstenhttps://stocksharp.com/users/99799/info@stocksharp.comI have a windows service that hosts a web api interface. The service connects to an interactive broker TWS. A call to the web api must lookup the security and return the Id. The code to do this is:<br /> var criteria = new SecurityLookupMessage()<br /> {<br /> Class = "",<br /> ExpiryDate = DateTimeOffset.Parse(expiryDate),<br /> OptionType = optionType == null ? default(OptionTypes?) : (OptionTypes)Enum.Parse(typeof(OptionTypes), optionType),<br /> Strike = strike,<br /> UnderlyingSecurityCode = underlyingSecurityCode,<br /> SecurityType = securityType == null ? default(SecurityTypes?) : (SecurityTypes)Enum.Parse(typeof(SecurityTypes), securityType),<br /> };<br /><br /> var security = _connector.Securities.FirstOrDefault(s =><br /> (s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) &&<br /> (s.Board?.Code == boardCode) &&<br /> (s.Class == @class) &&<br /> (s.Type == criteria.SecurityType) &&<br /> (s.ExpiryDate == criteria.ExpiryDate) &&<br /> (s.OptionType == criteria.OptionType) &&<br /> (s.Strike == criteria.Strike));<br /><br /> if (security == null)<br /> {<br /> var onNewSecurity = new Action<Security>(s =><br /> {<br /> if ((!s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) ||<br /> (s.Type != criteria.SecurityType) ||<br /> (s.Board?.Code != boardCode) ||<br /> (s.Class != @class) || <br /> (s.ExpiryDate != criteria.ExpiryDate) ||<br /> (s.OptionType != criteria.OptionType) ||<br /> (s.Strike != criteria.Strike) )<br /> return;<br /><br /> waitHandle.Set();<br /> });<br /><br /> _connector.NewSecurity += onNewSecurity;<br /><br /> _connector.LookupSecurities(criteria);<br /><br /> waitHandle.WaitOne(30000);<br /><br /> _connector.NewSecurity -= onNewSecurity;<br /><br /> security = _connector.Securities.FirstOrDefault(s =><br /> (s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) &&<br /> (s.Board?.Code == boardCode) &&<br /> (s.Class == @class) &&<br /> (s.Type == criteria.SecurityType) &&<br /> (s.ExpiryDate == criteria.ExpiryDate) &&<br /> (s.OptionType == criteria.OptionType) &&<br /> (s.Strike == criteria.Strike));<br /> }<br /><br />If I search for "SPZ7@GLOBEX" and then "SPXW 171215C02580000@SMART" it works fine. But if I first search for "SPXW 171215C02580000@SMART", then it cannot find "SPZ7@GLOBEX". It is like the option prohibits the searching of the future. Also, sometimes if I search for the option first, then it only finds "SPXW 171215C02580000@ALL" and "SPXW 171215C02580000@CBOE", but then if I search again no search returns "SPXW 171215C02580000@SMART". It is like the incomplete loaded results prohibit the later loading of extra results.