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


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


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

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

Теги:


Спасибо:


esper

Фотография
Дата: 20.09.2013
Ответить


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

vk37

Фотография
Дата: 20.09.2013
Ответить


Код
_securitiesToRegister = new[] { "RI@CONTINUOUS" };

Код
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;
}

Код
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();
        }
    }
}
Спасибо:


Добавить файлы через драг-н-дроп, , или вставить из буфера обмена.

loading
clippy