WhenMarketDepthChanged для ContinuousSecurity не срабатывает

WhenMarketDepthChanged для ContinuousSecurity не срабатывает
Atom
9/19/2013
vk37


Версия 4.1.19.
Code
  public class MyStrategy : Strategy
  {
      protected override void OnStarted()
      {
          Security.WhenMarketDepthChanged().Do(() =>
          {
              // Срабатывает если Security типа Security
              // Не срабатывает если Security типа ContinuousSecurity
          })
          .Apply(this);

          base.OnStarted();
      }
  }
Правила типа WhenNewTrades, WhenChanged для ContinuousSecurity срабатывают.

Tags:


Thanks:


esper

Avatar
Date: 9/20/2013
Reply


Покажите код где создаете сам инструмент.
Thanks:

vk37

Avatar
Date: 9/20/2013
Reply


Code
_securitiesToRegister = new[] { "RI@CONTINUOUS" };

Code
var waitForContinuousSecuritiesToBeBuildTask = Task.Factory.StartNew(() =>
{
    if (_securitiesToRegister != null)
    {
        foreach (var continuousSecurityId in _securitiesToRegister.Where(s => s.EndsWith("@CONTINUOUS")))
        {
            var continuousSecurity = new ContinuousSecurity()
            {
                ExchangeBoard = ExchangeBoard.Forts,
                Id = continuousSecurityId,
            };

            foreach (var component in ContinuousSecurityStore.GetComponents(continuousSecurityId).Where(c => c.Value > Trader.CurrentTime))
            {
                Security security = null;

                while (security == null)
                {
                    security = Trader.Securities.FirstOrDefault(s => 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("Составные инструменты не сформированы в заданный отрезок времени");
    return ConnectSuccess = false;
}

Code
public class ContinuousSecurityStore
{
    public static Dictionary<string, DateTime> GetComponents(string continuousSecurityId)
    {
        switch (continuousSecurityId)
        {
            case "RI@CONTINUOUS":
                return new Dictionary<string, DateTime>()
                {
                    {"RIU3@FORTS", new DateTime(2013, 9, 16)},
                    {"RIZ3@FORTS", new DateTime(2013, 12, 16)},
                    {"RIH4@FORTS", new DateTime(2014, 3, 17)},
                };
            default:
                throw new NotSupportedException();
        }
    }
}
Thanks:


Attach files by dragging & dropping, , or pasting from the clipboard.

loading
clippy