Тестирование, используя стакан

Тестирование, используя стакан
Atom
10/25/2013


Добрый день! Есть ли у кого - то пример тестирования стратегии работающей со стаканом, при каждом его обновлении. Например, если лучший объем bid - лучший объем ask > 0 то... ну покупаем 1 лот.
P.S. В примерах нет, да и в справке я не смог понять как это сделать. Заранее благодарю.



Thanks:


pafnuty

Avatar
Date: 10/25/2013
Reply


Достаточно подписать стратегию на получение стаканов по заданному инструменту:
Code

  class MyStrategy : Strategy
  {
    ...

    protected override void OnStarted()
    {
      //  настраиваем получение данных,
      this.Trader.RegisterMarketDepth(this.Security);
      this.Trader.MarketDepthsChanged += On_TraderMarketDepthsChanged;
      base.OnStarted();
    }

    protected override void OnStopping()
    {
      this.Trader.MarketDepthsChanged -= On_TraderMarketDepthsChanged;
      this.Trader.UnRegisterMarketDepth(this.Security);
      base.OnStopping();
    }

    void On_TraderMarketDepthsChanged(IEnumerable<MarketDepth> depths)
    { 
      depths.ForEach(depth =>
      {
        if (depth.Security.Equals(this.Security))
          ProcessDepth(depth);
      });
    }

    private void ProcessDepth(MarketDepth depth)
    {
      // делаем с depth все, что угодно
      ...
    }
  }
Thanks:

nuan

Avatar
Date: 10/25/2013
Reply


Quote:
depths.ForEach

Quote:
Error 1 'System.Collections.Generic.IEnumerable<StockSharp.BusinessEntities.MarketDepth>' does not contain a definition for 'ForEach' and no extension method 'ForEach' accepting a first argument of type 'System.Collections.Generic.IEnumerable<StockSharp.BusinessEntities.MarketDepth>' could be found (are you missing a using directive or an assembly reference?) C:\Users\Nuan\Desktop\4.1.19\4.1.19\StockSharpEnterprise_4.1.19.1\Samples\Testing\SampleHistoryTesting\DepthStrategy.cs 39 20 SampleHistoryTesting

Что-то не совсем понял, что нужно подключить...
Не могли бы именно пример кинуть?
UPD: Разобрался. Спасибо )
Thanks:

Андрей Шабанов

Avatar
Date: 10/27/2013
Reply


ecng.collections?
Thanks:


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

loading
clippy