﻿<?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">WhenMarketDepthChanged для ContinuousSecurity не срабатывает</title>
  <id>~/topic/4000/whenmarketdepthchanged-dlya-continuoussecurity-ne-srabatyvaet/</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-04-19T13:14:43Z</updated>
  <logo>https://stocksharp.ru/images/logo.png</logo>
  <link href="https://stocksharp.ru/handlers/atom.ashx?category=topic&amp;id=4000" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.ru/posts/m/27543/</id>
    <title type="text">_securitiesToRegister = new { &amp;quot;RI@CONTINUOUS&amp;quot; }; var waitForContinuousSecuritiesToBeBuildTask = Task...</title>
    <published>2013-09-20T08:52:11Z</published>
    <updated>2013-09-20T08:52:11Z</updated>
    <author>
      <name>vk37</name>
      <uri>https://stocksharp.ru/users/6296/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;pre class="brush:csharp"&gt;
_securitiesToRegister = new[] { &amp;quot;RI@CONTINUOUS&amp;quot; };&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;pre class="brush:csharp"&gt;
var waitForContinuousSecuritiesToBeBuildTask = Task.Factory.StartNew(() =&amp;gt;
{
    if (_securitiesToRegister != null)
    {
        foreach (var continuousSecurityId in _securitiesToRegister.Where(s =&amp;gt; s.EndsWith(&amp;quot;@CONTINUOUS&amp;quot;)))
        {
            var continuousSecurity = new ContinuousSecurity()
            {
                ExchangeBoard = ExchangeBoard.Forts,
                Id = continuousSecurityId,
            };

            foreach (var component in ContinuousSecurityStore.GetComponents(continuousSecurityId).Where(c =&amp;gt; c.Value &amp;gt; Trader.CurrentTime))
            {
                Security security = null;

                while (security == null)
                {
                    security = Trader.Securities.FirstOrDefault(s =&amp;gt; s.Id == component.Key);
                    Thread.Sleep(100);
                }

                continuousSecurity.ExpirationJumps.Add(security, component.Value);
            }

            continuousSecurity.Trader = Trader;
            Securities.Add(continuousSecurity);
        }
    }
});

if (!waitForContinuousSecuritiesToBeBuildTask.Wait(TimeSpan.FromSeconds(15)))
{
    Log.ErrorFormat(&amp;quot;Составные инструменты не сформированы в заданный отрезок времени&amp;quot;);
    return ConnectSuccess = false;
}&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;pre class="brush:csharp"&gt;
public class ContinuousSecurityStore
{
    public static Dictionary&amp;lt;string, DateTime&amp;gt; GetComponents(string continuousSecurityId)
    {
        switch (continuousSecurityId)
        {
            case &amp;quot;RI@CONTINUOUS&amp;quot;:
                return new Dictionary&amp;lt;string, DateTime&amp;gt;()
                {
                    {&amp;quot;RIU3@FORTS&amp;quot;, new DateTime(2013, 9, 16)},
                    {&amp;quot;RIZ3@FORTS&amp;quot;, new DateTime(2013, 12, 16)},
                    {&amp;quot;RIH4@FORTS&amp;quot;, new DateTime(2014, 3, 17)},
                };
            default:
                throw new NotSupportedException();
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/27541/</id>
    <title type="text">Покажите код где создаете сам инструмент.</title>
    <published>2013-09-20T06:19:35Z</published>
    <updated>2013-09-20T06:19:35Z</updated>
    <author>
      <name>esper</name>
      <uri>https://stocksharp.ru/users/5990/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">Покажите код где создаете сам инструмент.</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/27533/</id>
    <title type="text">Версия 4.1.19. public class MyStrategy : Strategy { protected override void OnStarted() { Security.W...</title>
    <published>2013-09-19T11:39:09Z</published>
    <updated>2013-09-19T11:39:09Z</updated>
    <author>
      <name>vk37</name>
      <uri>https://stocksharp.ru/users/6296/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">Версия 4.1.19. &lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;pre class="brush:csharp"&gt;
  public class MyStrategy : Strategy
  {
      protected override void OnStarted()
      {
          Security.WhenMarketDepthChanged().Do(() =&amp;gt;
          {
              // Срабатывает если Security типа Security
              // Не срабатывает если Security типа ContinuousSecurity
          })
          .Apply(this);

          base.OnStarted();
      }
  }&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;Правила типа WhenNewTrades, WhenChanged для ContinuousSecurity срабатывают.</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>