﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">Problems with lookup of security</title>
  <id>~/topic/8770/problems-with-lookup-of-security/</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-06-15T07:55:13Z</updated>
  <logo>https://stocksharp.ru/images/logo.png</logo>
  <link href="https://stocksharp.ru/handlers/atom.ashx?category=topic&amp;id=8770" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.ru/posts/m/41436/</id>
    <title type="text">Hi Thank you, this worked for me Regards </title>
    <published>2017-10-31T22:39:52Z</published>
    <updated>2017-10-31T22:39:52Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.ru/users/99799/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thank you, this worked for me&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41434/</id>
    <title type="text">Johan Kirsten: Hi Thank you for the feedback. I can do what you suggest, but the reason for me loadi...</title>
    <published>2017-10-31T15:54:34Z</published>
    <updated>2017-10-31T15:54:34Z</updated>
    <author>
      <name>Mikhail Sukhov</name>
      <uri>https://stocksharp.ru/users/201/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="@message(41429)" rel="nofollow" target="_blank"&gt;Johan Kirsten&lt;/a&gt;:&lt;/strong&gt;
Hi&lt;/p&gt;
&lt;p&gt;Thank you for the feedback. I can do what you suggest, but the reason for me loading it in the way I did, is I do not want to load 300+ options. It takes time and memory. I want to load a specific set of options/futures into memory. Can I specify strike, expiry and optiontype in the examples you specified?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yes, you can put more filtering details. Here is sample how to filter by expiration date and option type. Strike also can be specified:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;connector.LookupSecurities(new Security
{
	Code = &amp;quot;SPX&amp;quot;,
	Board = new ExchangeBoard { Code = &amp;quot;GLOBEX&amp;quot; },
	Type = SecurityTypes.Option,
	Currency = CurrencyTypes.USD,
	ExpiryDate = new DateTime(2017, 12, 14).ApplyTimeZone(TimeZoneInfo.Utc),
	OptionType = OptionTypes.Call,
});
&lt;/code&gt;&lt;/pre&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41429/</id>
    <title type="text">Hi Thank you for the feedback. I can do what you suggest, but the reason for me loading it in the wa...</title>
    <published>2017-10-31T09:31:38Z</published>
    <updated>2017-10-31T09:31:38Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.ru/users/99799/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thank you for the feedback. I can do what you suggest, but the reason for me loading it in the way I did, is I do not want to load 300+ options. It takes time and memory. I want to load a specific set of options/futures into memory. Can I specify strike, expiry and optiontype in the examples you specified?&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41428/</id>
    <title type="text">Hello, IB do not provide search by futures or options codes. Only by underlying symbol. So for futur...</title>
    <published>2017-10-31T02:49:32Z</published>
    <updated>2017-10-31T02:49:32Z</updated>
    <author>
      <name>Support</name>
      <uri>https://stocksharp.ru/users/97869/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;IB do not provide search by futures or options codes. Only by underlying symbol. So for futures the lookup code should be&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;connector.LookupSecurities(new Security
{
	Code = &amp;quot;SPX&amp;quot;,
	Type = SecurityTypes.Future
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For options chain&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;connector.LookupSecurities(new Security
{
	Code = &amp;quot;SPX&amp;quot;,
	Board = new ExchangeBoard { Code = &amp;quot;GLOBEX&amp;quot; },
	Type = SecurityTypes.Option,
	Currency = CurrencyTypes.USD,
});
&lt;/code&gt;&lt;/pre&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41422/</id>
    <title type="text">I have a windows service that hosts a web api interface. The service connects to an interactive brok...</title>
    <published>2017-10-30T22:07:51Z</published>
    <updated>2017-10-30T22:07:51Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.ru/users/99799/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;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:
var criteria = new SecurityLookupMessage()
{
Class = &amp;quot;&amp;quot;,
ExpiryDate = DateTimeOffset.Parse(expiryDate),
OptionType = optionType == null ? default(OptionTypes?) : (OptionTypes)Enum.Parse(typeof(OptionTypes), optionType),
Strike = strike,
UnderlyingSecurityCode = underlyingSecurityCode,
SecurityType = securityType == null ? default(SecurityTypes?) : (SecurityTypes)Enum.Parse(typeof(SecurityTypes), securityType),
};&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                    var security = _connector.Securities.FirstOrDefault(s =&amp;gt;
                        (s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) &amp;amp;&amp;amp;
                        (s.Board?.Code == boardCode) &amp;amp;&amp;amp;
                        (s.Class == @class) &amp;amp;&amp;amp;
                        (s.Type == criteria.SecurityType) &amp;amp;&amp;amp;
                        (s.ExpiryDate == criteria.ExpiryDate) &amp;amp;&amp;amp;
                        (s.OptionType == criteria.OptionType) &amp;amp;&amp;amp;
                        (s.Strike == criteria.Strike));

                    if (security == null)
                    {
                        var onNewSecurity = new Action&amp;lt;Security&amp;gt;(s =&amp;gt;
                        {
                            if ((!s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) ||
                                (s.Type != criteria.SecurityType) ||
                                (s.Board?.Code != boardCode) ||
                                (s.Class != @class) || 
                                (s.ExpiryDate != criteria.ExpiryDate) ||
                                (s.OptionType != criteria.OptionType) ||
                                (s.Strike != criteria.Strike) )
                                return;

                            waitHandle.Set();
                        });

                        _connector.NewSecurity += onNewSecurity;

                        _connector.LookupSecurities(criteria);

                        waitHandle.WaitOne(30000);

                        _connector.NewSecurity -= onNewSecurity;

                        security = _connector.Securities.FirstOrDefault(s =&amp;gt;
                            (s.UnderlyingSecurityId.StartsWith(criteria.UnderlyingSecurityCode)) &amp;amp;&amp;amp;
                            (s.Board?.Code == boardCode) &amp;amp;&amp;amp;
                            (s.Class == @class) &amp;amp;&amp;amp;
                            (s.Type == criteria.SecurityType) &amp;amp;&amp;amp;
                            (s.ExpiryDate == criteria.ExpiryDate) &amp;amp;&amp;amp;
                            (s.OptionType == criteria.OptionType) &amp;amp;&amp;amp;
                            (s.Strike == criteria.Strike));
                    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&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.&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>