[BUG] BatchStrategy - Value cannot be null. Parameter name: security
пытаюсь использовать TakeProfitStrategy и StopLossStrategy.
ловлю событие OnNewTrades и для трейдов которые принадлежат стратегии вызываю метод:
Code
private void CoverTrades(IEnumerable<MyTrade> trades)
{
var batch = new BatchStrategy(BatchFinishModes.All); // { IsParallel = true };
// для каждой сделки добавляем для защиты по пакетной стратегии
foreach (MyTrade t in trades)
{
var s = new BatchStrategy(BatchFinishModes.First);
var takeProfit = new TakeProfitStrategy(t, this.TakeProfitThreshold);
//takeProfit.BestPriceOffset = 0m.Pips(t.Order.Security);
//takeProfit.PriceOffset = 0m.Pips(t.Order.Security);
//takeProfit.MaxErrorCount = 2;
//takeProfit.UseMarketQuoting = true;
var stopLoss = new StopLossStrategy(t, this.StopLossThreshold);
//stopLoss.BestPriceOffset = 0m.Pips(t.Order.Security);
//stopLoss.PriceOffset = 0m.Pips(t.Order.Security);
//stopLoss.MaxErrorCount = 2;
//stopLoss.UseMarketQuoting = true;
this.AddInfoLog("Trade is protected. trade price was: {0}", t.Trade.Price);
s.ChildStrategies.Add(takeProfit);
s.ChildStrategies.Add(stopLoss);
batch.ChildStrategies.Add(s);
}
this.ChildStrategies.Add(batch);
}
в последней строчке возникает эксепшн:
Message "Value cannot be null.\r\nParameter name: security" string
StackTrace " at StockSharp.Algo.Strategies.StrategyRuleConditionHelper.#=q5t20hZ5NhMsnLhhoVmupPA==..ctor(Security #=qyOMCKzzXfCVNZ_GTO6s6Mw==)\r\n at StockSharp.Algo.Strategies.StrategyRuleConditionHelper.#=qE_i7$K1H6gPzl54YI1f60g22aN8KJNIzpQoV8M31CwU=..ctor(Security #=qZ_BCqXMY5Y$FSVkvqc$gSQ==)\r\n at StockSharp.Algo.Strategies.StrategyRuleConditionHelper.MarketDepthChanged(Security security)\r\n at StockSharp.Algo.Strategies.QuotingStrategy.OnRunning()\r\n at StockSharp.Algo.Strategies.Strategy.#=qF80M91vO$wL4Q_hdDt07aGyTnplCad9glUG6su24s3s=(StrategyProcessStates #=qVD6DbfnzbeUZEh8lM7LurA==)\r\n at StockSharp.Algo.Strategies.Strategy.#=qXB1Yax1xNzLXbDjRPCi7tCznkY9B4AmNwgAE8teNSnbLKOZ7pea69ymbJ6ftrBi8(Strategy #=qrdDj0efX3T7$tYfaMwHvSQ==)\r\n at Ecng.Collections.CollectionHelper.ForEach[T](IEnumerable`1 source, Action`1 action)\r\n at StockSharp.Algo.Strategies.Strategy.#=q3VsDgMm8EXknr4XwbQrzykk558DdB7AhrA0MenkIG4mOslFGa0jsUnoLXmPep_w$(IStrategyChildStrategyList #=qc8MS2wPBl0aYmiPlK7OPpw==)\r\n at Ecng.Collections.CollectionHelper.SyncDo[TCollection](TCollection collection, Action`1 action)\r\n at StockSharp.Algo.Strategies.Strategy.#=qqFxvsG_qDTMVCsiaiuO627TvkpI1QdJuWpQNBvO9AJ4=()\r\n at StockSharp.Algo.Strategies.Strategy.#=qF80M91vO$wL4Q_hdDt07aGyTnplCad9glUG6su24s3s=(StrategyProcessStates #=qVD6DbfnzbeUZEh8lM7LurA==)\r\n at StockSharp.Algo.Strategies.Strategy.#=qXB1Yax1xNzLXbDjRPCi7tCznkY9B4AmNwgAE8teNSnbLKOZ7pea69ymbJ6ftrBi8(Strategy #=qrdDj0efX3T7$tYfaMwHvSQ==)\r\n at Ecng.Collections.CollectionHelper.ForEach[T](IEnumerable`1 source, Action`1 action)\r\n at StockSharp.Algo.Strategies.Strategy.#=q3VsDgMm8EXknr4XwbQrzykk558DdB7AhrA0MenkIG4mOslFGa0jsUnoLXmPep_w$(IStrategyChildStrategyList #=qc8MS2wPBl0aYmiPlK7OPpw==)\r\n at Ecng.Collections.CollectionHelper.SyncDo[TCollection](TCollection collection, Action`1 action)\r\n at StockSharp.Algo.Strategies.Strategy.#=qqFxvsG_qDTMVCsiaiuO627TvkpI1QdJuWpQNBvO9AJ4=()\r\n at StockSharp.Algo.Strategies.Strategy.#=qF80M91vO$wL4Q_hdDt07aGyTnplCad9glUG6su24s3s=(StrategyProcessStates #=qVD6DbfnzbeUZEh8lM7LurA==)\r\n at StockSharp.Algo.Strategies.Strategy.#=qsJWnJ8ZS9kSeAG1NqJcSp94tYPTlnBSEn47C45iDRy4=.OnAdding(Strategy #=qqSQo0oCIzWI6DLEPymMnJw==)\r\n at Ecng.Collections.BaseCollection`1.Add(T item)\r\n at Ecng.Collections.SynchronizedCollection`1.Add(T item)\r\n at MyTrading.StrategiesLib.LimitStatArb.CoverTrades(IEnumerable`1 trades) in C:\\MyProjects\\MyTrading\\StrategiesLib\\LimitStatArb.cs:line 69\r\n at MyTrading.StrategiesLib.LimitStatArb.Trader_NewMyTrades(IEnumerable`1 trades) in C:\\MyProjects\\MyTrading\\StrategiesLib\\LimitStatArb.cs:line 37\r\n at System.Action`1.Invoke(T obj)\r\n at Ecng.Common.DelegateHelper.SafeInvoke[T](Action`1 handler, T arg)\r\n at StockSharp.Algo.Testing.RealTimeEmulationTrader`1.#=qhrvZySd33X_Q1SUCxf9oHwTQM__bQsMfo6Ro$Vha9u8=(IEnumerable`1 #=q4cgjILI8t5UOKN9_Pe_4AA==)\r\n at Ecng.Common.DelegateHelper.SafeInvoke[T](Action`1 handler, T arg)\r\n at StockSharp.Algo.Testing.MarketEmulator.RaiseNewMyTrades(IEnumerable`1 trades)\r\n at StockSharp.Algo.Testing.MarketEmulator.#=qEs$l0LvYhUYco3GGJLa5Eg==(Order #=qyVorZok67K51uOTgGrDkZg==, Int32 #=qBpUMVYqCJzL6R934ZM7bfw==, Decimal #=q5IDE$gbf5rRP8Otn1c4lGg==)\r\n at StockSharp.Algo.Testing.MarketEmulator.#=q09JR5JSudo6W2SF8rRogNaemQQj9SvO8f6qfU4UJ6X0=(MarketDepth #=qkR4xVruXydpTJT6goOjVUA==, Order #=qOLTChJHz0$_wWdGKO8a6bg==, Quote #=qc62acyKRiEqBWmUljTXhkw==, Boolean #=qYlKiojNUC81EB4Oszvgf62Y9Z_OzVquViVi0HzEnfNk=)\r\n at StockSharp.Algo.Testing.MarketEmulator.#=qY7ZKrEE2PZZbw_nJENCeJITZxF4l1pc9UH2JbVicIcI=(Order #=qsv6eKFrooFYED5AtXg3W5Q==, MarketDepth #=qrb3r5_EyE_lzdjYf1MQESQ==)\r\n at StockSharp.Algo.Testing.MarketEmulator.#=qeAmKRIl9XhEvkcdH_dOhbg==(SynchronizedDictionary`2 #=q41csUsfkEwhy5_L12UKUFw==)\r\n at Ecng.Collections.CollectionHelper.SyncDo[TCollection](TCollection collection, Action`1 action)\r\n at StockSharp.Algo.Testing.MarketEmulator.Emulate()\r\n at StockSharp.Algo.Testing.MarketEmulator.UpdateQuotes(IEnumerable`1 marketDepths)\r\n at StockSharp.Algo.Testing.RealTimeEmulationTrader`1.#=qMpi1M1KJMzur45zCCnhMeb0RCRP7LJozIcjoJQn_TZE=(IEnumerable`1 #=qK1FO3nQWTP8MUVNFADz9nA==)\r\n at Ecng.Common.DelegateHelper.SafeInvoke[T](Action`1 handler, T arg)\r\n at StockSharp.Algo.BaseTrader.#=qCShKTbqJTVmmfu48SmdzkIqhq_f$ljv1HDBVbsnofCQ=.#=qoxhUX87tcowE4b51IGMQCg==(IEnumerable`1 #=qhBbuGOwsDBAEQciofJ5UXg==)" string
PS. возможно это как-то связано с
http://stocksharp.com/fo...-nulievoi-shagh-tsieny/ ?