﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.com/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.com/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">lookupsecurities. StockSharp</title>
  <id>https://stocksharp.com/handlers/atom.ashx?category=tag&amp;id=lookupsecurities&amp;type=forum</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-04-04T13:26:11Z</updated>
  <logo>https://stocksharp.com/images/logo.png</logo>
  <link href="https://stocksharp.com/handlers/atom.ashx?category=tag&amp;id=lookupsecurities&amp;type=forum" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.com/topic/8770/</id>
    <title type="text">Problems with lookup of security</title>
    <published>2017-10-30T22:07:51Z</published>
    <updated>2017-10-31T22:39:52Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.com/users/99799/</uri>
      <email>info@stocksharp.com</email>
    </author>
    <category term="LookupSecurities" />
    <category term="SecurityLookupMessage" />
    <content type="html">I 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:&lt;br /&gt;                        var criteria = new SecurityLookupMessage()&lt;br /&gt;                        {&lt;br /&gt;                            Class = &amp;quot;&amp;quot;,&lt;br /&gt;                            ExpiryDate = DateTimeOffset.Parse(expiryDate),&lt;br /&gt;                            OptionType = optionType == null ? default(OptionTypes?) : (OptionTypes)Enum.Parse(typeof(OptionTypes), optionType),&lt;br /&gt;                            Strike = strike,&lt;br /&gt;                            UnderlyingSecurityCode = underlyingSecurityCode,&lt;br /&gt;                            SecurityType = securityType == null ? default(SecurityTypes?) : (SecurityTypes)Enum.Parse(typeof(SecurityTypes), securityType),&lt;br /&gt;                        };&lt;br /&gt;&lt;br /&gt;                        var security = _connector.Securities.FirstOrDefault(s =&amp;gt;&lt;br /&gt;                            (s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) &amp;amp;&amp;amp;&lt;br /&gt;                            (s.Board?.Code == boardCode) &amp;amp;&amp;amp;&lt;br /&gt;                            (s.Class == @class) &amp;amp;&amp;amp;&lt;br /&gt;                            (s.Type == criteria.SecurityType) &amp;amp;&amp;amp;&lt;br /&gt;                            (s.ExpiryDate == criteria.ExpiryDate) &amp;amp;&amp;amp;&lt;br /&gt;                            (s.OptionType == criteria.OptionType) &amp;amp;&amp;amp;&lt;br /&gt;                            (s.Strike == criteria.Strike));&lt;br /&gt;&lt;br /&gt;                        if (security == null)&lt;br /&gt;                        {&lt;br /&gt;                            var onNewSecurity = new Action&amp;lt;Security&amp;gt;(s =&amp;gt;&lt;br /&gt;                            {&lt;br /&gt;                                if ((!s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) ||&lt;br /&gt;                                    (s.Type != criteria.SecurityType) ||&lt;br /&gt;                                    (s.Board?.Code != boardCode) ||&lt;br /&gt;                                    (s.Class != @class) || &lt;br /&gt;                                    (s.ExpiryDate != criteria.ExpiryDate) ||&lt;br /&gt;                                    (s.OptionType != criteria.OptionType) ||&lt;br /&gt;                                    (s.Strike != criteria.Strike) )&lt;br /&gt;                                    return;&lt;br /&gt;&lt;br /&gt;                                waitHandle.Set();&lt;br /&gt;                            });&lt;br /&gt;&lt;br /&gt;                            _connector.NewSecurity += onNewSecurity;&lt;br /&gt;&lt;br /&gt;                            _connector.LookupSecurities(criteria);&lt;br /&gt;&lt;br /&gt;                            waitHandle.WaitOne(30000);&lt;br /&gt;&lt;br /&gt;                            _connector.NewSecurity -= onNewSecurity;&lt;br /&gt;&lt;br /&gt;                            security = _connector.Securities.FirstOrDefault(s =&amp;gt;&lt;br /&gt;                                (s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) &amp;amp;&amp;amp;&lt;br /&gt;                                (s.Board?.Code == boardCode) &amp;amp;&amp;amp;&lt;br /&gt;                                (s.Class == @class) &amp;amp;&amp;amp;&lt;br /&gt;                                (s.Type == criteria.SecurityType) &amp;amp;&amp;amp;&lt;br /&gt;                                (s.ExpiryDate == criteria.ExpiryDate) &amp;amp;&amp;amp;&lt;br /&gt;                                (s.OptionType == criteria.OptionType) &amp;amp;&amp;amp;&lt;br /&gt;                                (s.Strike == criteria.Strike));&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;If I search for &amp;quot;SPZ7@GLOBEX&amp;quot; and then &amp;quot;SPXW  171215C02580000@SMART&amp;quot; it works fine. But if I first search for &amp;quot;SPXW  171215C02580000@SMART&amp;quot;, then it cannot find &amp;quot;SPZ7@GLOBEX&amp;quot;. It is like the option prohibits the searching of the future. Also, sometimes if I search for the option first, then it only finds  &amp;quot;SPXW  171215C02580000@ALL&amp;quot; and  &amp;quot;SPXW  171215C02580000@CBOE&amp;quot;, but then if I search again no search returns &amp;quot;SPXW  171215C02580000@SMART&amp;quot;. It is like the incomplete loaded results prohibit the later loading of extra results.</content>
  </entry>
</feed>